/* Shared Featured / Explore story cards */

.story-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.story-cards-section .story-card {
  position: relative;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 356px;
  border: 1px solid var(--ff-border);
  border-radius: var(--ff-radius-lg);
  background: var(--ff-surface);
  box-shadow: var(--ff-shadow-soft);
  overflow: hidden;
  transition:
    transform var(--ff-transition),
    box-shadow var(--ff-transition),
    border-color var(--ff-transition),
    background var(--ff-transition);
}

.story-cards-section .story-card.story-card-clickable {
  cursor: pointer;
}

.story-cards-section .story-card:hover,
.story-cards-section .story-card:focus-within {
  transform: translateY(-2px);
  border-color: var(--ff-primary);
  box-shadow: var(--ff-shadow-glow);
}

.story-cards-section .story-card:focus-visible {
  outline: 3px solid rgba(124, 58, 237, 0.28);
  outline-offset: 2px;
}

.story-cards-section .story-cover {
  position: relative;
  z-index: 2;
  height: 248px;
  width: 100%;
  overflow: hidden;
  border-radius: var(--ff-radius-lg) var(--ff-radius-lg) 0 0;
}

.story-cards-section .story-cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.story-cards-section .story-bookmark-ribbon {
  position: absolute;
  z-index: 4;
  top: 0;
  left: 12px;
  width: 18px;
  height: 28px;
  pointer-events: none;
  background: linear-gradient(180deg, #fbbf24 0%, var(--ff-warning) 72%, #d97706 100%);
  box-shadow: 0 2px 6px rgba(217, 119, 6, 0.35);
  clip-path: polygon(0 0, 100% 0, 100% 100%, 50% 78%, 0 100%);
}

.story-cards-section .status {
  position: absolute;
  z-index: 3;
  top: var(--ff-space-3);
  right: var(--ff-space-3);
  left: auto;
  display: inline-flex;
  align-items: center;
  padding: 4px 9px;
  font-size: 11px;
  font-weight: 600;
  line-height: 1.2;
  border-radius: 999px;
  color: var(--ff-text-secondary);
  border: 1px solid rgba(154, 160, 179, 0.28);
  background: rgba(5, 7, 18, 0.56);
  backdrop-filter: blur(6px);
  box-shadow: none;
  cursor: default;
}

.story-cards-section .status.ongoing {
  color: #4ade80;
  border-color: rgba(74, 222, 128, 0.4);
}

.story-cards-section .status.finished {
  color: #c4b5fd;
  border-color: rgba(196, 181, 253, 0.42);
}

body[data-theme="dark"] .story-cards-section .status.finished,
.ff-theme-dark .story-cards-section .status.finished {
  color: #ddd6fe;
  border-color: rgba(196, 181, 253, 0.58);
}

.story-cards-section .story-card-body {
  position: relative;
  z-index: 2;
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
  padding: 12px 12px 10px;
}

.story-cards-section .story-card h3 {
  margin: 0;
  font: 500 17px / 1.3 var(--ff-font-serif);
  color: var(--ff-text);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.story-cards-section .story-card h3.story-title a {
  color: inherit;
  text-decoration: none;
}

.story-cards-section .story-author-row {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  width: 100%;
}

.story-cards-section .story-author {
  margin: 0;
  min-width: 0;
  flex: 0 1 auto;
  font-size: 12px;
  color: var(--ff-text-secondary);
  overflow: hidden;
}

.story-cards-section .story-author-text {
  display: block;
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.story-cards-section .story-author-row .story-badge.is-owner {
  flex: 0 0 auto;
  min-height: 22px;
  padding: 0 7px;
  font-size: 0.62rem;
}

.story-cards-section .story-meta-compact {
  margin: 0;
  font-size: 12px;
  color: var(--ff-text-muted);
  white-space: nowrap;
  text-overflow: ellipsis;
  overflow: hidden;
}

.story-cards-section .story-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0;
}

.story-cards-section .story-badge {
  min-height: 24px;
  display: inline-flex;
  align-items: center;
  border: 1px solid rgba(154, 160, 179, 0.22);
  border-radius: 999px;
  padding: 0 8px;
  color: var(--ff-text-secondary);
  background: rgba(255, 255, 255, 0.04);
  font-size: 0.66rem;
  font-weight: 700;
  line-height: 1;
}

.story-cards-section .story-badge.is-owner {
  border-color: rgba(124, 58, 237, 0.45);
  color: #d8b4fe;
  background: rgba(124, 58, 237, 0.13);
}

.story-cards-section .story-badge.is-progress {
  border-color: rgba(41, 98, 255, 0.38);
  color: #93c5fd;
  background: rgba(41, 98, 255, 0.12);
}

body[data-theme="light"] .story-cards-section .story-badge,
.ff-theme-light .story-cards-section .story-badge {
  border-color: #e4e0f3;
  color: #585d83;
  background: #fbfaff;
}

body[data-theme="light"] .story-cards-section .story-badge.is-owner,
.ff-theme-light .story-cards-section .story-badge.is-owner {
  border-color: #c4b5fd;
  color: #5b21b6;
  background: #f5f1ff;
}

body[data-theme="light"] .story-cards-section .story-badge.is-progress,
.ff-theme-light .story-cards-section .story-badge.is-progress {
  border-color: #bfdbfe;
  color: #1d4ed8;
  background: #eff6ff;
}

.story-cards-section .story-tags {
  margin-top: 8px;
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 8px;
  min-width: 0;
  width: 100%;
  overflow: hidden;
}

/* Shared interactive chip language: Featured card tags + Popular Tags */
.story-cards-section .story-tags .ff-tag,
.popular .tag-cloud .ff-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  border-color: #e4e0f3;
  color: #4e5278;
  background: #fbfaff;
  text-decoration: none;
  cursor: pointer;
  pointer-events: auto;
  position: relative;
  z-index: 2;
  transition:
    border-color var(--ff-transition),
    color var(--ff-transition),
    background var(--ff-transition);
}

.story-cards-section .story-tags .ff-tag {
  flex: 0 1 auto;
  min-width: 0;
  max-width: 100%;
  min-height: 24px;
  padding-inline: 8px;
  font-size: 0.72rem;
  overflow: hidden;
}

.story-cards-section .story-tags .ff-tag::before,
.popular .tag-cloud .ff-tag::before {
  flex: 0 0 auto;
}

.story-cards-section .story-tags .ff-tag .story-tag-label {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.story-cards-section .story-tags .ff-tag:hover,
.popular .tag-cloud .ff-tag:hover {
  border-color: #a78bfa;
  color: #6d28d9;
  background: #f5f1ff;
}

.story-cards-section .story-tags .ff-tag:hover::before,
.popular .tag-cloud .ff-tag:hover::before {
  color: #7c3aed;
}

.story-cards-section .story-tags .ff-tag:active,
.popular .tag-cloud .ff-tag:active {
  border-color: #8b5cf6;
  color: #5b21b6;
  background: #ede9fe;
}

.story-cards-section .story-tags .ff-tag:focus-visible,
.popular .tag-cloud .ff-tag:focus-visible {
  outline: 3px solid rgba(124, 58, 237, 0.24);
  outline-offset: 2px;
}

.story-cards-section .story-tag-more {
  color: var(--ff-text-muted);
  font-size: 0.7rem;
  font-weight: 500;
  line-height: 1;
  flex: 0 0 auto;
  white-space: nowrap;
  cursor: default;
  user-select: none;
  pointer-events: none;
}

.story-cards-section .card-actions {
  margin-top: auto;
  padding: 12px 0 2px;
  display: block;
}

.story-cards-section .card-actions .ff-btn {
  width: 100%;
  position: relative;
  z-index: 2;
}

.story-cards-section .card-actions .story-read-action {
  cursor: pointer;
}

.story-cards-section .card-actions .story-read-action:hover {
  border-color: var(--ff-primary-hover);
  background: linear-gradient(135deg, var(--ff-primary-hover), var(--ff-primary));
}

.story-cards-section .card-actions .story-read-action:active {
  filter: brightness(0.96);
}

.story-cards-section .card-actions .story-read-action:focus-visible {
  border-color: var(--ff-primary-hover);
  box-shadow: var(--ff-glow-violet);
  outline: 0;
}

.story-cards-section .card-actions .ff-btn-secondary {
  display: none;
}

.story-cards-section .is-disabled {
  opacity: 0.45;
  pointer-events: none;
}

body[data-theme="dark"] .story-cards-section .story-card,
.ff-theme-dark .story-cards-section .story-card {
  border-color: #222c40;
  background: #09101c;
  box-shadow: none;
}

body[data-theme="dark"] .story-cards-section .story-card h3,
.ff-theme-dark .story-cards-section .story-card h3 {
  color: #f5f2ef;
}

body[data-theme="dark"] .story-cards-section .story-tags .ff-tag,
.ff-theme-dark .story-cards-section .story-tags .ff-tag,
body[data-theme="dark"] .popular .tag-cloud .ff-tag,
.ff-theme-dark .popular .tag-cloud .ff-tag {
  border-color: #36245b;
  color: #c47cff;
  background: transparent;
}

body[data-theme="dark"] .story-cards-section .story-tags .ff-tag::before,
.ff-theme-dark .story-cards-section .story-tags .ff-tag::before,
body[data-theme="dark"] .popular .tag-cloud .ff-tag::before,
.ff-theme-dark .popular .tag-cloud .ff-tag::before {
  color: #d8b4fe;
}

body[data-theme="dark"] .story-cards-section .story-tags .ff-tag:hover,
.ff-theme-dark .story-cards-section .story-tags .ff-tag:hover,
body[data-theme="dark"] .popular .tag-cloud .ff-tag:hover,
.ff-theme-dark .popular .tag-cloud .ff-tag:hover {
  border-color: rgba(167, 139, 250, 0.72);
  color: #e9d5ff;
  background: rgba(124, 58, 237, 0.16);
}

body[data-theme="dark"] .story-cards-section .story-tags .ff-tag:hover::before,
.ff-theme-dark .story-cards-section .story-tags .ff-tag:hover::before,
body[data-theme="dark"] .popular .tag-cloud .ff-tag:hover::before,
.ff-theme-dark .popular .tag-cloud .ff-tag:hover::before {
  color: #f5f3ff;
}

body[data-theme="dark"] .story-cards-section .story-tags .ff-tag:active,
.ff-theme-dark .story-cards-section .story-tags .ff-tag:active,
body[data-theme="dark"] .popular .tag-cloud .ff-tag:active,
.ff-theme-dark .popular .tag-cloud .ff-tag:active {
  border-color: rgba(196, 181, 253, 0.8);
  color: #f5f3ff;
  background: rgba(124, 58, 237, 0.24);
}

body[data-theme="light"] .story-cards-section .story-tags .ff-tag:hover,
.ff-theme-light .story-cards-section .story-tags .ff-tag:hover,
body[data-theme="light"] .popular .tag-cloud .ff-tag:hover,
.ff-theme-light .popular .tag-cloud .ff-tag:hover {
  border-color: #a78bfa;
  color: #6d28d9;
  background: #f5f1ff;
}

body[data-theme="light"] .story-cards-section .story-tags .ff-tag:active,
.ff-theme-light .story-cards-section .story-tags .ff-tag:active,
body[data-theme="light"] .popular .tag-cloud .ff-tag:active,
.ff-theme-light .popular .tag-cloud .ff-tag:active {
  border-color: #8b5cf6;
  color: #5b21b6;
  background: #ede9fe;
}

body[data-theme="dark"] .story-cards-section .story-card:hover,
body[data-theme="dark"] .story-cards-section .story-card:focus-within,
.ff-theme-dark .story-cards-section .story-card:hover,
.ff-theme-dark .story-cards-section .story-card:focus-within {
  box-shadow: 0 0 0 1px rgba(124, 58, 237, 0.34), 0 10px 20px rgba(0, 0, 0, 0.36);
}

@media (max-width: 1050px) {
  .story-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 760px) {
  .story-grid {
    grid-template-columns: 1fr;
  }

  .story-cards-section .story-card {
    min-height: 338px;
  }

  .story-cards-section .story-cover {
    height: 230px;
  }
}
