/* Reset truncation and improve chapter list appearance */
.story__chapters .chapter-group__list-item {
  padding: 0.4rem 0.6rem;
  transition: background-color 0.2s ease, transform 0.1s ease;
  border-radius: 4px;
  margin: 0.1rem 0;
}

.story__chapters .chapter-group__list-item:hover {
  background-color: var(--bg-50, rgba(0, 0, 0, 0.02));
  transform: translateY(-1px);
}

.story__chapters .chapter-group__list-item-link {
  white-space: normal !important;
  overflow: visible !important;
  text-overflow: clip !important;
  max-width: 100% !important;
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  text-decoration: none;
  color: inherit;
}

.story__chapters .truncate._1-1 {
  -webkit-line-clamp: unset !important;
  white-space: normal !important;
  overflow: visible !important;
  text-overflow: clip !important;
}

/* Title row styling - Desktop */
.chapter-title-row {
  display: flex;
  flex-direction: column; /* Stack title, divider, and short title vertically */
  align-items: flex-start;
  margin-bottom: 0.1rem;
}

.chapter-main-title {
  font-weight: 700; /* Bold */
  font-size: 0.75rem; /* Very small font */
  color: var(--fg-500, #777); /* Greyed out */
  text-transform: uppercase; /* All caps */
  line-height: 1.2;
}

/* When no short title exists, style the main title differently */
.chapter-title-row:not(:has(.chapter-short-title)) .chapter-main-title {
  text-transform: capitalize; /* First letter of every word capitalized */
  font-size: 0.75rem; /* Larger font when no short title */
  font-weight: 600;
  color: var(--fg-900, #1a1a1a);
}

.chapter-main-title:hover {
  color: var(--accent-700, #0055cc);
}

.title-separator {
  width: 100%;
  height: 1px;
  margin: 0.2rem 0; /* Space above and below the divider */
  background: var(--fg-400, #999);
  opacity: 0.5;
}

.chapter-short-title {
  font-weight: 600;
  font-size: 0.75rem;
  color: var(--fg-900, #1a1a1a);
  text-transform: none; /* Handled by PHP (ucwords) */
  line-height: 1.2;
}

/* Meta row styling (base) */
.chapter-meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  font-size: 0.8rem;
  color: var(--fg-600, #666);
  line-height: 1.1;
  align-items: center;
}

/* Price box styling (base) */
.chapter-price {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.1rem 0.4rem;
  border-radius: 3px;
  font-family: 'Arial', sans-serif;
  font-weight: 600;
  font-size: 0.8em;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
  transition: background-color 0.2s ease;
}

/* Specific price states */
.chapter-price.purchased {
  background-color: var(--success-50, rgba(0, 128, 0, 0.1));
  color: var(--success-700, #006400);
}

.chapter-price.free {
  background-color: var(--accent-50, rgba(0, 100, 255, 0.08));
  color: var(--accent-700, #0055cc);
}

.chapter-price.unpurchased {
  background-color: var(--warning-50, rgba(255, 165, 0, 0.1));
  color: var(--warning-700, #ff8c00);
}

.chapter-price:hover {
  filter: brightness(1.1);
}

/* Desktop date styling */
.chapter-expiration,
.chapter-date {
  display: inline-flex;
  align-items: center;
  font-family: 'Arial', sans-serif;
  font-size: 0.8rem;
  color: var(--fg-700, #444);
  margin-right: 0.3rem;
}

/* Two-column layout for mobile/grid view */
.meta-columns {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
  margin-top: 0.05rem;
}

.meta-left {
  flex: 0 0 auto;
}

.meta-right {
  flex: 1 1 auto;
  position: relative;
  padding-left: 0.6rem;
}

/* Vertical separator */
.meta-right::before {
  content: "";
  position: absolute;
  left: 0;
  top: 20%;
  bottom: 20%;
  width: 1px;
  background: var(--fg-300, #d1d1d1);
  opacity: 0.6;
}

/* Mobile/grid date styling */
.meta-right .chapter-expiration,
.meta-right .chapter-date {
  display: flex;
  align-items: center;
  font-family: 'Arial', sans-serif;
  font-size: 0.75rem;
  color: var(--fg-700, #444);
  margin-bottom: 0.1rem;
}

.meta-right .chapter-date:last-child {
  margin-bottom: 0;
}

/* SVG icon styling */
.icon-unlock,
.icon-calendar {
  width: 0.8em;
  height: 0.8em;
  margin-right: 0.2rem;
  flex-shrink: 0;
}

.icon-unlock path,
.icon-calendar path {
  stroke: var(--fg-800, #2a2a2a);
  stroke-width: 1.5;
}

/* Date value */
.date-value {
  color: var(--fg-600, #666);
}

/* Mobile view */
@media only screen and (max-width: 640px) {
  .chapter-title-row {
    flex-direction: column;
    align-items: flex-start;
    margin-bottom: 0.05rem;
  }

  .chapter-main-title {
    font-size: 0.7rem; /* Slightly smaller for mobile */
  }

  /* When no short title exists, style the main title differently */
  .chapter-title-row:not(:has(.chapter-short-title)) .chapter-main-title {
    font-size: 0.75rem; /* Slightly smaller for mobile */
  }

  .title-separator {
    margin: 0.15rem 0; /* Slightly less space in mobile */
  }

  .chapter-short-title {
    font-size: 0.75rem; /* Slightly smaller for mobile */
  }

  .story__chapters .chapter-group__list-item {
    padding: 0.3rem 0.6rem;
    margin: 0.05rem 0;
    border-bottom: 1px solid var(--fg-200, #f0f0f0);
    border-radius: 3px;
  }

  .chapter-price {
    font-size: 0.75em;
    padding: 0.1rem 0.4rem;
  }

  .meta-columns {
    gap: 0.4rem;
    margin-top: 0.03rem;
  }

  .meta-right {
    padding-left: 0.5rem;
  }
}

/* Grid view adjustments */
.story__chapters[data-view="grid"] .chapter-title-row {
  flex-direction: column;
  align-items: flex-start;
  margin-bottom: 0.05rem;
}

.story__chapters[data-view="grid"] .chapter-main-title {
  font-size: 0.7rem;
}

.story__chapters[data-view="grid"] .chapter-title-row:not(:has(.chapter-short-title)) .chapter-main-title {
  font-size: 0.75rem;
}

.story__chapters[data-view="grid"] .title-separator {
  margin: 0.15rem 0;
}

.story__chapters[data-view="grid"] .chapter-short-title {
  font-size: 0.75rem;
}

.story__chapters[data-view="grid"] .chapter-group__list-item {
  padding: 0.3rem 0.6rem;
  margin: 0.05rem 0;
  border-radius: 3px;
}

.story__chapters[data-view="grid"] .chapter-price {
  font-size: 0.75em;
  padding: 0.1rem 0.4rem;
}

/* Dark mode adjustments */
:root[data-mode="dark"] .story__chapters .chapter-group__list-item {
  border-bottom: 1px solid var(--fg-700, #444);
}

:root[data-mode="dark"] .story__chapters .chapter-group__list-item:hover {
  background-color: var(--bg-700, rgba(255, 255, 255, 0.05));
}

:root[data-mode="dark"] .chapter-main-title {
  color: var(--fg-400, #bbb);
}

:root[data-mode="dark"] .chapter-title-row:not(:has(.chapter-short-title)) .chapter-main-title {
  color: var(--fg-200, #e0e0e0);
}

:root[data-mode="dark"] .chapter-main-title:hover {
  color: var(--accent-300, #66aaff);
}

:root[data-mode="dark"] .chapter-short-title {
  color: var(--fg-200, #e0e0e0);
}

:root[data-mode="dark"] .chapter-price.purchased {
  background-color: var(--success-900, rgba(0, 128, 0, 0.2));
  color: var(--success-300, #00ff00);
}

:root[data-mode="dark"] .chapter-price.free {
  background-color: var(--accent-900, rgba(0, 100, 255, 0.2));
  color: var(--accent-300, #66aaff);
}

:root[data-mode="dark"] .chapter-price.unpurchased {
  background-color: var(--warning-900, rgba(255, 165, 0, 0.2));
  color: var(--warning-300, #ffcc66);
}

:root[data-mode="dark"] .chapter-price:hover {
  filter: brightness(1.2);
}

:root[data-mode="dark"] .chapter-expiration,
:root[data-mode="dark"] .chapter-date,
:root[data-mode="dark"] .meta-right .chapter-expiration,
:root[data-mode="dark"] .meta-right .chapter-date {
  color: var(--fg-300, #ccc);
}

:root[data-mode="dark"] .date-value {
  color: var(--fg-400, #bbb);
}

:root[data-mode="dark"] .icon-unlock path,
:root[data-mode="dark"] .icon-calendar path {
  stroke: var(--fg-300, #ccc);
}

:root[data-mode="dark"] .meta-right::before {
  background: var(--fg-600, #666);
}

:root[data-mode="dark"] .title-separator {
  background: var(--fg-600, #666);
}