/* Story Page Styles */
.temp {
  position: fixed;
  inset: 0;
  background-color: white; /* modal background */
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;

  max-width: 500px;
  width: 100%; /* responsive width */
  min-height: 85vh;
  padding: 30px;
  border-radius: 12px; /* smooth corners */

  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.25), 0 4px 6px rgba(0, 0, 0, 0.1);

  display: none; /* hidden by default */
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  overflow-y: auto;
}

.settings-control {
  position: fixed;
  bottom: 3%;
  right: 20%;
  transform: translateY(0);
}
.settings-control button {
  background-color: rgb(19, 59, 84);
  border-radius: 30%;
  color: white;
  padding: 10px;
}

/* Mobile & Tablet */
@media (max-width: 991px) {
  .offcanvas-mobile-bottom {
    height: 50vh !important;        /* half of screen height */
    max-height: 50vh !important;    /* enforce max */
    width: 100% !important;         /* full width */
    border-radius: 12px 12px 0 0;  
  }

  .offcanvas-mobile-bottom.show {
    content: '';
    display: block;
    width: 40px;
    height: 4px;
    border-radius: 4px;
    margin: 0 auto 12px;
  }
}

/* Desktop stays right-side */
@media (min-width: 992px) {
  .offcanvas-mobile-bottom {
    height: 100%; /* full height on desktop */
    width: 320px;
  }
}

/* Reading progress bar */
#reading-progress {
  position: fixed;
  top: 0;
  left: 0;
  height: 3px;
  width: 0%;
  background: linear-gradient(90deg, var(--gold), var(--gold-light));
  z-index: 9998;
  transition: width 0.1s linear;
}

/* Story hero */
.story-hero {
  background: var(--ink);
  padding: 4rem 1.5rem 3rem;
  text-align: center;
  position: relative;
  overflow: hidden;
}

.story-hero::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(
      ellipse at 15% 60%,
      rgba(184, 147, 90, 0.18) 0%,
      transparent 55%
    ),
    radial-gradient(
      ellipse at 85% 30%,
      rgba(184, 147, 90, 0.1) 0%,
      transparent 50%
    );
  pointer-events: none;
}

.hero-back {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  color: rgba(249, 245, 239, 0.45);
  font-size: 0.78rem;
  text-decoration: none;
  letter-spacing: 0.04em;
  margin-bottom: 1.2rem;
  position: relative;
  z-index: 1;
  transition: color 0.2s;
}

.hero-back:hover {
  color: var(--gold-light);
}

.story-hero h1 {
  font-family: 'Roboto', sans-serif;
  font-size: clamp(1.6rem, 4vw, 2.5rem);
  color: var(--cream);
  font-weight: 700;
  position: relative;
  z-index: 1;
  margin-bottom: 0.5rem;
  line-height: 1.25;
}

.story-hero h1 span {
  color: var(--gold-light);
}

.hero-divider {
  width: 44px;
  height: 2px;
  background: var(--gold);
  margin: 1rem auto;
  position: relative;
  z-index: 1;
}

.story-hero p {
  color: rgba(249, 245, 239, 0.45);
  font-size: 0.85rem;
  font-weight: 400;
  max-width: none;
  margin: 0;
  line-height: normal;
  position: relative;
  z-index: 1;
}

/* Reading settings FAB */
.settings-fab {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--ink);
  color: var(--cream);
  border: 2px solid rgba(184, 147, 90, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  cursor: pointer;
  z-index: 900;
  box-shadow: 0 4px 18px rgba(26, 22, 18, 0.35);
  transition:
    background 0.2s,
    border-color 0.2s,
    transform 0.15s,
    opacity 0.3s ease,
    visibility 0.3s ease;
}

.settings-fab:hover {
  background: #2e2823;
  border-color: var(--gold);
  transform: scale(1.08);
  color: var(--gold-light);
}

.settings-fab.fab-hidden {
  opacity: 0;
  visibility: hidden;
  transform: scale(0.85);
  pointer-events: none;
}

/* Offcanvas settings drawer */
.offcanvas {
  font-family: 'Roboto', sans-serif;
  background: var(--surface);
  border-left: 1.5px solid var(--border) !important;
}

.offcanvas-header {
  background: var(--ink);
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.offcanvas-title {
  font-family: 'Roboto', sans-serif;
  color: var(--cream);
  font-size: 1.1rem;
  font-weight: 700;
}

.offcanvas-header .btn-close {
  filter: invert(1) brightness(0.7);
}

.offcanvas-body {
  padding: 1.5rem;
}

.settings-group-label {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 0.75rem;
}

/* Font size stepper */
.font-stepper {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.font-stepper-btn {
  width: 38px;
  height: 38px;
  border-radius: 8px;
  border: 1.5px solid var(--border);
  background: var(--cream);
  color: var(--ink);
  font-size: 0.9rem;
  font-weight: 600;
  font-family: 'Roboto', sans-serif;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition:
    border-color 0.18s,
    background 0.18s;
}

.font-stepper-btn:hover {
  border-color: var(--gold);
  background: var(--gold-pale);
}
.font-stepper-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.font-size-display {
  flex: 1;
  text-align: center;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--ink);
  border: 1.5px solid var(--border);
  border-radius: 8px;
  padding: 0.45rem;
  background: var(--cream);
}

/* Select */
.settings-select {
  width: 100%;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  padding: 0.6rem 0.9rem;
  font-size: 0.88rem;
  font-family: 'Roboto', sans-serif;
  background: var(--cream);
  color: var(--ink);
  transition: border-color 0.2s;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%237a6e62' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.85rem center;
}

.settings-select:focus {
  border-color: var(--gold);
  outline: none;
}

/* Theme swatches */
.theme-swatches {
  display: flex;
  gap: 0.5rem;
}

.theme-swatch {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: 2px solid transparent;
  cursor: pointer;
  transition:
    border-color 0.18s,
    transform 0.15s;
}

.theme-swatch:hover {
  transform: scale(1.1);
}
.theme-swatch.active {
  border-color: var(--gold);
}
.theme-swatch.cream {
  background: #f9f5ef;
  border-color: var(--border);
}
.theme-swatch.white {
  background: #ffffff;
  border-color: var(--border);
}
.theme-swatch.dark {
  background: #1a1612;
}
.theme-swatch.sepia {
  background: #f4e8d0;
  border-color: #d9c9a8;
}

.settings-divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 1.25rem 0;
}

/* Main reading area */
.story-layout {
  max-width: 720px;
  margin: 0 auto;
  padding: 3rem 1.5rem 2rem;
}

/* Quill story content overrides */
.ql-editor {
  font-family: 'Roboto', sans-serif;
  font-size: 17px;
  line-height: 1.85;
  color: var(--ink);
  padding: 0 !important;
  border: none !important;
  background: transparent !important;
}

.ql-editor p {
  margin-bottom: var(--para-spacing, 1.2em);
}
.ql-editor h1,
.ql-editor h2,
.ql-editor h3 {
  font-family: 'Roboto', sans-serif;
  color: var(--ink);
  margin: 1.5em 0 0.5em;
}

.ql-editor img {
  max-width: 100%;
  height: auto;
  border-radius: 10px;
  margin: 1.5rem auto;
  display: block;
  box-shadow: 0 4px 20px rgba(26, 22, 18, 0.1);
}

/* Loading skeleton for story content */
.story-skeleton {
  padding: 0;
}
.skel-para {
  height: 13px;
  border-radius: 6px;
  background: linear-gradient(
    90deg,
    var(--cream-dark) 25%,
    var(--cream) 50%,
    var(--cream-dark) 75%
  );
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite;
  margin-bottom: 0.75rem;
}

@keyframes shimmer {
  0% {
    background-position: 200% 0;
  }
  100% {
    background-position: -200% 0;
  }
}

/* Section divider */
.section-break {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin: 2.5rem 0;
  color: var(--border);
}

.section-break::before,
.section-break::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border);
}

.section-break i {
  color: var(--gold);
  font-size: 0.9rem;
}

/* Section cards (Q&A, QFT, Prayer) */
.section-card {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: 14px;
  padding: 2rem;
  margin-bottom: 1.5rem;
}

.section-card-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}

.section-card-icon {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: var(--gold-pale);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--gold);
  font-size: 1rem;
  flex-shrink: 0;
}

.section-card-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--ink);
}

/* Q&A */
.qa-block {
  margin-bottom: 1.75rem;
}
.qa-block:last-child {
  margin-bottom: 0;
}

.question-text {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--ink);
  margin-bottom: 0.85rem;
  line-height: 1.5;
}

.options {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.option-label {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.7rem 1rem;
  border-radius: 99px;
  cursor: pointer;
  border: 1.5px solid var(--border);
  background: var(--cream);
  transition:
    border-color 0.18s,
    background 0.18s;
  font-size: 0.9rem;
  color: var(--ink);
}

.option-label:hover {
  border-color: var(--gold);
  background: var(--gold-pale);
}
.option-input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.option-icon {
  width: 24px;
  height: 24px;
  border-radius: 6px;
  border: 1.5px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  background: #fff;
  flex-shrink: 0;
  transition: all 0.15s;
}

.option-label.correct {
  border-color: #27ae60;
  background: rgba(39, 174, 96, 0.07);
}

.option-label.correct .option-icon {
  background: #27ae60;
  border-color: #27ae60;
  color: #fff;
}

.option-label.wrong {
  border-color: #e74c3c;
  background: rgba(231, 76, 60, 0.07);
}

.option-label.wrong .option-icon {
  background: #e74c3c;
  border-color: #e74c3c;
  color: #fff;
}

/* Blurred content */
.blurred-content {
  filter: blur(6px);
  pointer-events: none;
  opacity: 0.9;
  transition:
    filter 0.3s ease,
    opacity 0.3s ease;
  user-select: none;
}

.blurred-content.revealed {
  filter: none;
  pointer-events: auto;
  opacity: 1;
}

.unlock-hint {
  text-align: center;
  padding: 0.75rem;
  font-size: 0.82rem;
  color: var(--muted);
  background: var(--gold-pale);
  border-radius: 8px;
  margin-top: 0.75rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
}

.unlock-hint i {
  color: var(--gold);
}

/* QFT & Prayer content */
.qft-content p,
.prayer-content p {
  font-size: 0.93rem;
  color: var(--muted);
  line-height: 1.75;
  margin-bottom: 0.75rem;
}

.qft-content p:last-child,
.prayer-content p:last-child {
  margin-bottom: 0;
}

/* Comments */
.comments-card {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: 14px;
  overflow: hidden;
  margin-bottom: 2rem;
}

.comments-header {
  padding: 1.25rem 1.75rem;
  background: var(--ink);
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.comments-header h4 {
  font-family: 'Roboto', sans-serif;
  color: var(--cream);
  font-size: 1.1rem;
  font-weight: 700;
  margin: 0;
}

.comments-header i {
  color: var(--gold);
}

.comments-body {
  padding: 1.75rem;
}

/* Comment form */
.comment-form textarea {
  border: 1.5px solid var(--border);
  border-radius: 10px;
  padding: 0.85rem 1rem;
  font-size: 0.9rem;
  font-family: 'Roboto', sans-serif;
  background: var(--cream);
  color: var(--ink);
  resize: vertical;
  min-height: 100px;
  width: 100%;
  transition:
    border-color 0.2s,
    box-shadow 0.2s;
}

.comment-form textarea:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(184, 147, 90, 0.12);
  outline: none;
}

.comment-form textarea::placeholder {
  color: #bbb3a8;
}

.btn-comment {
  background: var(--ink);
  color: var(--cream);
  border: none;
  border-radius: 8px;
  padding: 0.65rem 1.4rem;
  font-size: 0.88rem;
  font-weight: 500;
  font-family: 'Roboto', sans-serif;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  transition:
    background 0.18s,
    transform 0.15s;
  margin-top: 0.75rem;
}

.btn-comment:hover {
  background: #2e2823;
  color: var(--gold-light);
  transform: translateY(-1px);
}
.btn-comment:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

/* Comments list */
.comments-divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 1.5rem 0;
}

.comment-item {
  display: flex;
  gap: 0.9rem;
  padding: 1rem 0;
  border-bottom: 1px solid var(--border);
}

.comment-item:last-child {
  border-bottom: none;
}

.comment-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--gold-pale);
  border: 1.5px solid rgba(184, 147, 90, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--gold);
  font-size: 0.85rem;
  font-weight: 700;
  font-family: 'Roboto', sans-serif;
  flex-shrink: 0;
}

.comment-name {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--ink);
  margin-bottom: 0.2rem;
}

.comment-text {
  font-size: 0.88rem;
  color: var(--muted);
  line-height: 1.65;
  margin-bottom: 0.3rem;
}

.comment-time {
  font-size: 0.72rem;
  color: #a89e95;
  letter-spacing: 0.02em;
}

.comment-actions {
  display: flex;
  gap: 1rem;
  margin-top: 0.4rem;
}

.btn-action {
  background: none;
  border: none;
  padding: 0;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.3rem;
  transition: color 0.15s;
}

.btn-action:hover {
  color: var(--gold);
}

.btn-action.btn-delete:hover {
  color: #e74c3c;
}

.comment-loading {
  text-align: center;
  padding: 1.5rem;
  color: var(--muted);
  font-size: 0.88rem;
}

/* Scripture strip */
.scripture-strip {
  background: var(--ink);
  padding: 3rem 1.5rem;
  text-align: center;
  position: relative;
  overflow: hidden;
}

.scripture-strip::before {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(
    ellipse at 50% 50%,
    rgba(184, 147, 90, 0.12) 0%,
    transparent 70%
  );
}

.scripture-strip blockquote {
  font-style: italic;
  font-size: clamp(1.05rem, 2.5vw, 1.4rem);
  color: rgba(249, 245, 239, 0.75);
  max-width: 560px;
  margin: 0 auto;
  line-height: 1.75;
  position: relative;
  z-index: 1;
}

.scripture-strip cite {
  display: block;
  font-family: 'Roboto', sans-serif;
  font-style: normal;
  font-size: 0.78rem;
  color: var(--gold-light);
  margin-top: 0.75rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

/* Dark theme override */
body.theme-dark {
  --cream: #121010;
  --cream-dark: #1c1816;
  --ink: #f0ebe4;
  --muted: #9e9189;
  --border: #2e2823;
  --surface: #1a1612;
}

body.theme-dark .story-hero {
  background: var(--cream-dark);
}
body.theme-dark .story-hero h1 {
  color: var(--ink);
}
body.theme-dark .hero-back {
  color: var(--muted);
}
body.theme-dark .story-hero p {
  color: var(--muted);
}

body.theme-sepia {
  --cream: #f4e8d0;
  --cream-dark: #ecdfc4;
  --surface: #fdf6e3;
  --border: #d9c9a8;
}

body.theme-white {
  --cream: #ffffff;
  --cream-dark: #f5f5f5;
  --surface: #ffffff;
}

@media (max-width: 575.98px) {
  .story-layout {
    padding: 2rem 1rem 1.5rem;
  }
  .section-card {
    padding: 1.25rem;
  }
  .settings-fab {
    bottom: 1.2rem;
    right: 1.2rem;
  }

  /* Mobile: offcanvas slides from bottom */
  .offcanvas-bottom-mobile {
    width: 100% !important;
    max-height: 80vh;
    border-radius: 16px 16px 0 0;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    top: auto !important;
  }
}

.btn-complete-chapter {
  background: var(--gold);
  color: var(--ink);
  border: none;
  border-radius: 10px;
  padding: 1rem 2rem;
  font-size: 1rem;
  font-weight: 700;
  font-family: 'Roboto', sans-serif;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  width: 100%;
  margin-top: 1.5rem;
  transition: all 0.2s;
  box-shadow: 0 4px 15px rgba(184, 147, 90, 0.2);
}

.btn-complete-chapter:hover {
  background: var(--gold-light);
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(184, 147, 90, 0.3);
}

.btn-complete-chapter:disabled {
  opacity: 0.7;
  cursor: not-allowed;
  transform: none;
}

.btn-complete-chapter.btn-completed {
  background: #27ae60;
  color: #fff;
  box-shadow: none;
}

/* Chapter Navigation */
.chapter-actions-wrapper {
  margin-top: 2rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  width: 100%;
}

.chapter-nav-container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  width: 100%;
}

.btn-nav-chapter {
  flex: 1;
  background: var(--ink);
  color: var(--gold-light);
  border: 1.5px solid var(--gold);
  border-radius: 10px;
  padding: 0.9rem 1.5rem;
  font-size: 0.95rem;
  font-weight: 600;
  font-family: 'Roboto', sans-serif;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: 0 4px 12px rgba(184, 147, 90, 0.05);
}

.btn-nav-chapter:hover {
  background: var(--gold-pale);
  color: var(--ink);
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(184, 147, 90, 0.15);
}

.btn-nav-chapter:active {
  transform: translateY(0);
}

/* Non-logged in Gate Card */
.auth-gate-card {
  background: linear-gradient(135deg, rgba(184, 147, 90, 0.05), rgba(184, 147, 90, 0.01));
  border: 1.5px dashed var(--gold);
  border-radius: 12px;
  padding: 2.2rem 1.5rem;
  text-align: center;
  margin: 1.5rem 0;
  box-shadow: 0 8px 30px rgba(0,0,0,0.02);
  animation: fadeIn 0.4s ease-out;
}

.auth-gate-card i {
  font-size: 2.2rem;
  color: var(--gold);
  margin-bottom: 0.8rem;
  display: inline-block;
}

.auth-gate-card h4 {
  font-family: 'Roboto', sans-serif;
  font-weight: 700;
  color: var(--ink);
  margin-bottom: 0.5rem;
}

.auth-gate-card p {
  color: var(--muted);
  font-size: 0.9rem;
  max-width: 420px;
  margin: 0 auto 1.2rem;
  line-height: 1.5;
}

.auth-gate-buttons {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
}

.auth-gate-btn {
  padding: 0.6rem 1.5rem;
  border-radius: 8px;
  font-size: 0.88rem;
  font-weight: 600;
  font-family: 'Roboto', sans-serif;
  text-decoration: none;
  transition: all 0.2s;
}

.auth-gate-btn-primary {
  background: var(--gold);
  color: var(--ink);
  border: none;
  box-shadow: 0 4px 10px rgba(184, 147, 90, 0.15);
}

.auth-gate-btn-primary:hover {
  background: var(--gold-light);
  color: var(--ink);
  transform: translateY(-1px);
}

.auth-gate-btn-secondary {
  background: transparent;
  color: var(--ink);
  border: 1.5px solid var(--border);
}

.auth-gate-btn-secondary:hover {
  background: rgba(0, 0, 0, 0.03);
  border-color: var(--ink);
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Reading Mask */
#reading-mask-top, #reading-mask-bottom {
  position: fixed;
  left: 0;
  right: 0;
  background: rgba(0, 0, 0, 0.82);
  z-index: 800;
  pointer-events: none;
  display: none;
}
#reading-mask-top {
  top: 0;
}
#reading-mask-bottom {
  bottom: 0;
}
body.mask-active #reading-mask-top,
body.mask-active #reading-mask-bottom {
  display: block;
}
