/**
 * Minimalist Chapter Header Styling
 */

/* Variables */
:root[data-mode="light"] {
  --ch-primary: rgba(30, 30, 40, 0.88);
  --ch-secondary: rgba(60, 60, 70, 0.72);
  --ch-tertiary: rgba(90, 90, 100, 0.6);
  --ch-link: #3a7bd5;
  --ch-link-hover: #2c5fa3;
  --ch-separator: rgba(0, 0, 0, 0.06);
  --ch-container-bg: rgba(250, 250, 255, 0.35);
  --ch-border: rgba(0, 0, 0, 0.04);
  --ch-group-bg: rgba(245, 245, 250, 0.6);
  --ch-title-border: rgba(0, 0, 0, 0.07);
  --ch-second-title-bg: rgba(248, 248, 252, 0.4);
  --ch-shadow: 0 1px 2px rgba(0, 0, 0, 0.03);
}

:root[data-mode="dark"] {
  --ch-primary: rgba(240, 240, 250, 0.9);
  --ch-secondary: rgba(220, 220, 230, 0.75);
  --ch-tertiary: rgba(200, 200, 210, 0.65);
  --ch-link: #6d9ee8;
  --ch-link-hover: #8ab1f0;
  --ch-separator: rgba(255, 255, 255, 0.06);
  --ch-container-bg: rgba(35, 35, 45, 0.3);
  --ch-border: rgba(255, 255, 255, 0.04);
  --ch-group-bg: rgba(45, 45, 55, 0.5);
  --ch-title-border: rgba(255, 255, 255, 0.06);
  --ch-second-title-bg: rgba(40, 40, 50, 0.4);
  --ch-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

/* Container */
.chapter__headline {
  margin: 0.5rem auto 2rem;
  text-align: center;
  line-height: 1.25;
  max-width: 600px;
}

/* Story link */
.chapter-story-container {
  margin-bottom: 0.75rem;
  display: inline-block;
  transition: all 0.2s ease;
}

.chapter-story-container:hover {
  transform: translateY(-1px);
}

.chapter__story-link {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--ch-link);
  text-decoration: none;
  padding: 0.15rem 0.6rem;
  border-radius: 3px;
  background: var(--ch-container-bg);
  border: 1px solid var(--ch-border);
}

.chapter__story-link::before {
  content: "📖";
  font-size: 0.75rem;
  margin-right: 0.2rem;
  opacity: 0.8;
}

.chapter__story-link:hover {
  color: var(--ch-link-hover);
}

/* Author */
.chapter__author {
  font-size: 0.75rem;
  font-style: italic;
  color: var(--ch-secondary);
  margin-top: 0.1rem;
}

/* Title container */
.chapter-title-container {
  padding: 0.8rem 0.7rem;
  margin: 0 auto;
  background: var(--ch-container-bg);
  border-radius: 5px;
  border: 1px solid var(--ch-border);
  box-shadow: var(--ch-shadow);
  position: relative;
}

/* Chapter group */
.chapter__group {
  font-size: 0.7rem;
  font-weight: 500;
  color: var(--ch-tertiary);
  margin-bottom: 0.5rem;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  background: var(--ch-group-bg);
  display: inline-block;
  padding: 0.12rem 0.6rem;
  border-radius: 2px;
}

/* Main title */
.chapter__title {
  font-size: 1.3rem;
  font-weight: 600;
  color: var(--ch-primary);
  margin: 0 auto 0.4rem;
  line-height: 1.2;
  padding: 0.2rem 0 0.3rem;
  border-bottom: 1px solid var(--ch-title-border);
  max-width: 90%;
}

/* Second title */
.chapter__second-title,
:where(article, .content-section) .chapter-title-container .chapter__second-title,
.chapter-title-container h2.chapter__second-title,
header .chapter__second-title,
body .chapter__headline .chapter__second-title {
  font-size: 0.8rem !important;
  font-weight: 400 !important;
  font-style: italic !important;
  color: var(--ch-secondary) !important;
  margin: 0.05rem auto 0 !important;
  line-height: 1.2 !important;
  background: var(--ch-second-title-bg);
  display: inline-block;
  padding: 0.1rem 0.5rem;
  border-radius: 2px;
  max-width: 85%;
  text-transform: none !important;
  letter-spacing: normal !important;
}

/* Divider */
.chapter-story-container::before {
  content: "";
  display: block;
  width: 24px;
  height: 1px;
  background: var(--ch-separator);
  margin: 0 auto 0.5rem;
  transition: width 0.2s ease;
}

/* Responsive */
@media (max-width: 768px) {
  .chapter-title-container {
    padding: 0.7rem 0.6rem;
  }
  
  .chapter__title {
    font-size: 1.2rem;
  }
}

@media (max-width: 480px) {
  .chapter__headline {
    margin-bottom: 1.5rem;
  }
  
  .chapter-title-container {
    padding: 0.6rem 0.5rem;
  }
  
  .chapter__title {
    font-size: 1.1rem;
  }
  
  .chapter__second-title,
  :where(article, .content-section) .chapter-title-container .chapter__second-title,
  header .chapter__second-title {
    font-size: 0.75rem !important;
    padding: 0.08rem 0.4rem;
  }
}

/* Password protected */
.chapter__title._password::after {
  content: "🔒";
  font-size: 0.8rem;
  position: absolute;
  right: -1.2rem;
  top: 50%;
  transform: translateY(-50%);
  opacity: 0.7;
}