/* =========================================================
   CCcD — Cammina coraggiosamente con Dio
   Tema Scuro Grafite & Arancione Intenso (Mobile-First PWA)
   ========================================================= */

:root {
  --bg-main: #101418;
  --bg-card: #181F26;
  --bg-elevated: #1E2730;
  --border-card: #2A343E;
  --accent: #FF6600;
  --accent-soft: rgba(255, 102, 0, 0.14);
  --accent-hover: #FF7A1F;
  --text-main: #E8ECEF;
  --text-muted: #9AA6B2;
  --scripture: #64B5F6;
  --radius-card: 14px;
  --radius-pill: 999px;
  --max-w: 680px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html {
  background-color: var(--bg-main);
  color: var(--text-main);
  font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body {
  background-color: var(--bg-main);
  color: var(--text-main);
  min-height: 100dvh;
  overflow-x: hidden;
}

.hidden {
  display: none !important;
}

/* ===========================
   A. SPLASH SCREEN
   =========================== */
.splash-screen {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background-color: var(--bg-main);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  user-select: none;
  opacity: 1;
  transition: opacity 0.45s ease, visibility 0.45s ease;
}

.splash-screen.fade-out {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.splash-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  display: block;
}

@media (min-aspect-ratio: 3/4) {
  .splash-img {
    object-fit: contain;
    max-width: 100%;
    max-height: 100%;
  }
}

.splash-scrim {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 56px 24px calc(32px + var(--safe-bottom));
  background: linear-gradient(to top, rgba(16, 20, 24, 0.92) 0%, rgba(16, 20, 24, 0.55) 55%, rgba(16, 20, 24, 0) 100%);
  display: flex;
  justify-content: center;
  pointer-events: none;
}

.splash-cta {
  color: var(--text-main);
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  padding: 10px 24px;
  border-radius: var(--radius-pill);
  background: rgba(16, 20, 24, 0.55);
  border: 1px solid rgba(255, 102, 0, 0.55);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  animation: splashPulse 2.1s ease-in-out infinite;
}

@keyframes splashPulse {
  0%, 100% {
    opacity: 0.72;
    transform: scale(0.985);
  }
  50% {
    opacity: 1;
    transform: scale(1.02);
  }
}

/* ===========================
   SHARED HEADERS & CONTAINERS
   =========================== */
.view {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background-color: var(--bg-card);
  border-bottom: 2px solid var(--accent);
  padding-top: var(--safe-top);
}

.header-inner {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.home-title {
  display: flex;
  flex-direction: column;
  font-size: 1.18rem;
  line-height: 1.2;
  font-weight: 800;
  color: var(--accent);
  hyphens: none;
  -webkit-hyphens: none;
  word-break: keep-all;
  overflow-wrap: normal;
  letter-spacing: -0.01em;
}

.home-title span {
  white-space: nowrap;
}

@media (max-width: 350px) {
  .home-title {
    font-size: 1.05rem;
  }
}

.icon-btn {
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-main);
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: background-color 0.18s ease, color 0.18s ease, border-color 0.18s ease;
}

.icon-btn:hover,
.icon-btn:active {
  background-color: var(--bg-elevated);
  border-color: var(--border-card);
  color: var(--accent);
}

.main-container {
  width: 100%;
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 12px 16px calc(32px + var(--safe-bottom));
  flex: 1;
}

/* ===========================
   B. HOME: SEARCH & CHAPTERS
   =========================== */
.search-bar-wrap {
  width: 100%;
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 14px 16px 6px;
}

.search-input-box {
  position: relative;
  display: flex;
  align-items: center;
  background-color: var(--bg-card);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-pill);
  padding: 0 14px;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.search-input-box:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.search-icon {
  color: var(--text-muted);
  flex-shrink: 0;
}

#search-input {
  width: 100%;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text-main);
  font-size: 0.96rem;
  padding: 12px 10px;
  font-family: inherit;
}

#search-input::placeholder {
  color: var(--text-muted);
}

#search-input::-webkit-search-cancel-button {
  -webkit-appearance: none;
  appearance: none;
}

.search-clear {
  background: var(--bg-elevated);
  border: none;
  color: var(--text-muted);
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
}

.search-clear:hover {
  color: var(--text-main);
}

.part-section {
  margin-top: 18px;
}

.part-section:first-child {
  margin-top: 8px;
}

.part-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  padding-bottom: 8px;
  margin-bottom: 12px;
  border-bottom: 1.5px solid var(--accent);
}

.part-title {
  font-size: 0.86rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  color: var(--accent);
  text-transform: uppercase;
}

.part-progress {
  font-size: 0.78rem;
  color: var(--text-muted);
  white-space: nowrap;
  font-weight: 600;
}

.chapters-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.chapter-card {
  background-color: var(--bg-card);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-card);
  padding: 13px 14px;
  display: flex;
  align-items: center;
  gap: 13px;
  cursor: pointer;
  transition: border-color 0.18s ease, background-color 0.18s ease, transform 0.12s ease;
}

.chapter-card:active {
  transform: scale(0.992);
  background-color: var(--bg-elevated);
}

.chapter-card:hover {
  border-color: rgba(255, 102, 0, 0.55);
}

.chapter-card.is-studied {
  border-color: rgba(255, 102, 0, 0.4);
}

.chapter-num-badge {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background-color: var(--bg-elevated);
  border: 1px solid var(--border-card);
  color: var(--accent);
  font-weight: 800;
  font-size: 0.95rem;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.chapter-card.is-studied .chapter-num-badge {
  background-color: var(--accent-soft);
  border-color: rgba(255, 102, 0, 0.5);
}

.chapter-meta {
  flex: 1;
  min-width: 0;
}

.chapter-character {
  font-size: 0.98rem;
  font-weight: 700;
  color: var(--text-main);
  line-height: 1.25;
}

.chapter-subtitle {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 2px;
  line-height: 1.35;
}

.check-circle {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 2px solid var(--border-card);
  background: transparent;
  color: transparent;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: background-color 0.18s ease, border-color 0.18s ease, color 0.18s ease, transform 0.12s ease;
}

.check-circle:hover {
  border-color: var(--accent);
}

.check-circle.checked {
  background-color: var(--accent);
  border-color: var(--accent);
  color: #101418;
}

.check-circle:active {
  transform: scale(0.92);
}

.empty-state {
  text-align: center;
  padding: 48px 20px;
  color: var(--text-muted);
  font-size: 0.95rem;
}

/* ===========================
   C. CHAPTER SCREEN
   =========================== */
.chapter-header .header-inner {
  justify-content: flex-start;
  padding: 10px 12px;
}

.back-btn {
  margin-right: 2px;
}

.chapter-header-title {
  flex: 1;
  font-size: 1rem;
  font-weight: 800;
  color: var(--accent);
  line-height: 1.25;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.header-check {
  width: 28px;
  height: 28px;
}

.chapter-main {
  padding-top: 16px;
}

.chapter-hero {
  margin-bottom: 18px;
}

.chapter-hero-part {
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  text-transform: uppercase;
  margin-bottom: 4px;
}

.chapter-hero-title {
  font-size: 1.32rem;
  font-weight: 800;
  color: var(--text-main);
  line-height: 1.28;
}

/* Stacked Chapter Sections */
.study-section {
  padding: 18px 0;
  border-top: 1.5px solid var(--accent);
}

.study-section:first-of-type {
  padding-top: 14px;
}

.section-heading {
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--accent);
  margin-bottom: 12px;
  letter-spacing: 0.01em;
}

/* Section 1: Scriptures (STRICTLY ZERO LINKS) */
.scriptures-card {
  background-color: var(--bg-card);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-card);
  padding: 14px 16px;
}

.scriptures-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.scripture-item {
  position: relative;
  padding-left: 16px;
  color: var(--scripture);
  font-weight: 600;
  font-size: 0.98rem;
  line-height: 1.45;
  text-decoration: none;
  cursor: default;
}

.scripture-item::before {
  content: "•";
  position: absolute;
  left: 0;
  top: 0;
  color: var(--accent);
  font-weight: 900;
}

.scripture-ref {
  color: var(--scripture);
  text-decoration: none;
  cursor: default;
  font-weight: 500;
}

/* Question Cards */
.questions-stack {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.group-header-prompt {
  font-size: 0.96rem;
  font-weight: 700;
  color: var(--text-main);
  margin-top: 6px;
  margin-bottom: -4px;
  padding-left: 4px;
}

.question-card {
  background-color: var(--bg-card);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-card);
  overflow: hidden;
}

.question-body {
  padding: 15px 15px 12px;
}

.question-text {
  font-size: 0.98rem;
  font-weight: 600;
  color: var(--text-main);
  line-height: 1.5;
}

/* Inline Study Images (Immediately Visible under Question) */
.question-images {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 12px;
}

.study-figure {
  background-color: var(--bg-main);
  border: 1px solid var(--border-card);
  border-radius: 10px;
  overflow: hidden;
}

.study-figure-img-wrap {
  position: relative;
  background-color: #0b0e11;
  cursor: zoom-in;
}

.study-figure img {
  width: 100%;
  height: auto;
  display: block;
}

.study-figcaption {
  padding: 10px 12px;
  display: flex;
  align-items: flex-start;
  gap: 9px;
  background-color: rgba(16, 20, 24, 0.85);
  border-top: 1px solid var(--border-card);
}

.img-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 24px;
  height: 24px;
  padding: 0 7px;
  border-radius: 6px;
  background-color: var(--accent);
  color: #101418;
  font-size: 0.78rem;
  font-weight: 800;
  flex-shrink: 0;
  margin-top: 1px;
}

.img-description {
  font-size: 0.86rem;
  color: var(--text-main);
  line-height: 1.45;
  font-style: italic;
}

/* Accordion Bar & Panel */
.accordion-trigger {
  width: 100%;
  background-color: var(--bg-elevated);
  border: none;
  border-top: 1px solid var(--border-card);
  color: var(--text-muted);
  padding: 10px 15px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.86rem;
  font-weight: 600;
  transition: background-color 0.16s ease, color 0.16s ease;
}

.accordion-trigger:hover {
  color: var(--text-main);
}

.accordion-trigger[aria-expanded="true"] {
  color: var(--accent);
  background-color: rgba(255, 102, 0, 0.08);
}

.accordion-trigger-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

.dot-indicator {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background-color: var(--accent);
  display: inline-block;
}

.accordion-chevron {
  transition: transform 0.22s ease;
  flex-shrink: 0;
}

.accordion-trigger[aria-expanded="true"] .accordion-chevron {
  transform: rotate(180deg);
}

.accordion-panel {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows 0.24s ease;
}

.accordion-panel.open {
  grid-template-rows: 1fr;
}

.accordion-inner {
  overflow: hidden;
}

.accordion-content {
  padding: 14px 15px 16px;
  border-top: 1px solid var(--border-card);
  background-color: rgba(16, 20, 24, 0.35);
}

.answer-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}

.answer-label {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--accent);
}

.answer-edited-tag {
  font-size: 0.72rem;
  color: var(--text-muted);
  background: var(--bg-elevated);
  border: 1px solid var(--border-card);
  padding: 2px 7px;
  border-radius: 999px;
  margin-left: 6px;
  text-transform: none;
  letter-spacing: 0;
  font-weight: 600;
}

.answer-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.btn-micro {
  background-color: var(--bg-elevated);
  border: 1px solid var(--border-card);
  color: var(--text-main);
  font-family: inherit;
  font-size: 0.78rem;
  font-weight: 600;
  padding: 5px 10px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  cursor: pointer;
  transition: border-color 0.16s ease, color 0.16s ease, background-color 0.16s ease;
}

.btn-micro:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.btn-micro.accent {
  background-color: var(--accent);
  border-color: var(--accent);
  color: #101418;
}

.btn-micro.accent:hover {
  background-color: var(--accent-hover);
  color: #101418;
}

.answer-text {
  font-size: 0.94rem;
  line-height: 1.62;
  color: var(--text-main);
  white-space: pre-line;
}

.answer-editor-wrap {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.answer-textarea {
  width: 100%;
  min-height: 110px;
  background-color: var(--bg-main);
  border: 1px solid var(--accent);
  border-radius: 10px;
  color: var(--text-main);
  font-family: inherit;
  font-size: 0.93rem;
  line-height: 1.55;
  padding: 10px 12px;
  resize: vertical;
  outline: none;
}

.editor-buttons {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

/* Personal Notes Box */
.notes-box {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px dashed var(--border-card);
}

.notes-label {
  display: block;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.notes-textarea {
  width: 100%;
  min-height: 44px;
  background-color: var(--bg-main);
  border: 1px solid var(--border-card);
  border-radius: 10px;
  color: var(--text-main);
  font-family: inherit;
  font-size: 0.9rem;
  line-height: 1.5;
  padding: 10px 12px;
  resize: none;
  overflow: hidden;
  outline: none;
  transition: border-color 0.18s ease;
}

.notes-textarea::placeholder {
  color: var(--text-muted);
}

.notes-textarea:focus {
  border-color: var(--accent);
}

/* Chapter Footer Navigation */
.chapter-footer-nav {
  margin-top: 24px;
  padding-top: 18px;
  border-top: 1.5px solid var(--accent);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.btn-studied-banner {
  width: 100%;
  padding: 13px 16px;
  border-radius: var(--radius-card);
  border: 1px solid var(--border-card);
  background-color: var(--bg-card);
  color: var(--text-main);
  font-family: inherit;
  font-size: 0.94rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  cursor: pointer;
  transition: border-color 0.18s ease, background-color 0.18s ease, color 0.18s ease;
}

.btn-studied-banner.checked {
  background-color: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
}

.chapter-prev-next {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.nav-pill-btn {
  background-color: var(--bg-card);
  border: 1px solid var(--border-card);
  color: var(--text-main);
  padding: 11px 12px;
  border-radius: 12px;
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  text-align: center;
  transition: border-color 0.18s ease, color 0.18s ease;
}

.nav-pill-btn:hover:not(:disabled) {
  border-color: var(--accent);
  color: var(--accent);
}

.nav-pill-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

/* ===========================
   MODALS & LIGHTBOX & TOAST
   =========================== */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 500;
  background: rgba(8, 10, 12, 0.78);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 16px;
}

@media (min-width: 540px) {
  .modal-overlay {
    align-items: center;
  }
}

.modal-sheet {
  width: 100%;
  max-width: 440px;
  background-color: var(--bg-card);
  border: 1px solid var(--border-card);
  border-top: 2px solid var(--accent);
  border-radius: 18px;
  padding: 18px;
  margin-bottom: var(--safe-bottom);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.modal-header h3 {
  font-size: 1.08rem;
  color: var(--accent);
  font-weight: 800;
}

.modal-desc {
  font-size: 0.88rem;
  color: var(--text-muted);
  margin-bottom: 14px;
}

.backup-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 16px;
}

.stat-chip {
  background-color: var(--bg-main);
  border: 1px solid var(--border-card);
  border-radius: 10px;
  padding: 10px 8px;
  text-align: center;
}

.stat-value {
  display: block;
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--accent);
}

.stat-label {
  display: block;
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.modal-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.btn-primary,
.btn-secondary {
  width: 100%;
  padding: 13px 16px;
  border-radius: 12px;
  font-family: inherit;
  font-size: 0.94rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  border: 1px solid transparent;
  transition: opacity 0.16s ease, border-color 0.16s ease;
}

.btn-primary {
  background-color: var(--accent);
  color: #101418;
}

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

.btn-secondary {
  background-color: var(--bg-elevated);
  border-color: var(--border-card);
  color: var(--text-main);
}

.btn-secondary:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* Lightbox */
.lightbox-overlay {
  position: fixed;
  inset: 0;
  z-index: 800;
  background: rgba(10, 13, 16, 0.95);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.lightbox-close {
  position: fixed;
  top: calc(14px + var(--safe-top));
  right: 14px;
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  color: var(--text-main);
  width: 42px;
  height: 42px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 810;
}

.lightbox-content {
  max-width: 100%;
  max-height: 86dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.lightbox-content img {
  max-width: 100%;
  max-height: 70dvh;
  border-radius: 10px;
  border: 1px solid var(--border-card);
  object-fit: contain;
}

.lightbox-caption {
  max-width: 560px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  border-radius: 10px;
  padding: 10px 14px;
}

.lightbox-caption p {
  font-size: 0.88rem;
  color: var(--text-main);
  font-style: italic;
}

/* Toast */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(22px + var(--safe-bottom));
  transform: translateX(-50%);
  z-index: 900;
  background-color: var(--bg-elevated);
  color: var(--text-main);
  border: 1px solid var(--accent);
  border-radius: var(--radius-pill);
  padding: 10px 18px;
  font-size: 0.86rem;
  font-weight: 600;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
  max-width: calc(100vw - 32px);
  text-align: center;
}

/* Loading indicator */
.loading-card {
  background-color: var(--bg-card);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-card);
  padding: 28px 18px;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.94rem;
}
