.characters-section {
  background: var(--bg-section);
  max-width: 100%;
}

.characters-header {
  text-align: center;
  max-width: 600px;
  margin: 0 auto 4rem;
}

.char-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.5rem;
  max-width: 1100px;
  margin: 0 auto;
  /* Reserve vertical space before cards load to reduce layout shift.
     Cards are 3/4 portrait; reserve ~2 rows on desktop. */
  min-height: calc((min(100vw, 1100px) / 3) * (4/3) * 2);
}

/* The whole card is a link */
.char-card {
  display: block;
  text-decoration: none;
  color: inherit;
  position: relative;
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--bg-card);
  overflow: hidden;
  transition: transform 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease;
}

/* Portrait frame — mirrors the gallery slots on character pages */
.char-frame {
  aspect-ratio: 3 / 4;
  position: relative;
  background:
    repeating-linear-gradient(45deg, rgba(122, 96, 48, 0.05) 0 10px, transparent 10px 20px),
    var(--bg-deep);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.char-frame img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center top;
  transition: transform 0.6s ease, filter 0.6s ease;
  filter: brightness(0.72) saturate(0.85);
}

.char-frame .frame-empty {
  font-family: 'Cinzel', serif;
  font-size: 10px;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--text-dim);
  opacity: 0.5;
}

/* Text overlay (kept as before: name+role visible, quote on hover) */
.char-card-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.95) 0%, rgba(0, 0, 0, 0.35) 45%, transparent 75%);
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: 1.5rem;
  transition: opacity 0.3s;
  pointer-events: none;
}

.char-card-name {
  font-family: 'Cinzel', serif;
  font-size: 1.1rem;
  color: var(--gold-light);
  font-weight: 600;
  margin-bottom: 2px;
}

.char-card-role {
  font-size: 0.8rem;
  color: var(--text-dim);
  letter-spacing: 1px;
  font-style: italic;
  margin-bottom: 0.6rem;
}

.char-card-quote {
  font-size: 0.82rem;
  color: var(--text);
  font-style: italic;
  line-height: 1.4;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.4s, transform 0.4s;
  border-left: 2px solid var(--crimson);
  padding-left: 0.6rem;
}

/* Hover highlight: lift, gold border, soft glow, brighten art, reveal quote */
.char-card:hover {
  transform: translateY(-4px);
  border-color: var(--gold-dim);
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.7), 0 0 0 1px var(--gold-dim);
}

.char-card:hover .char-frame img {
  transform: scale(1.05);
  filter: brightness(0.95) saturate(1);
}

.char-card:hover .char-card-quote {
  opacity: 1;
  transform: translateY(0);
}

/* Corner arrow hint (links to the character page) */
.char-card::after {
  content: '\2197';
  position: absolute;
  top: 0.8rem;
  right: 0.9rem;
  font-size: 1.1rem;
  color: var(--gold-light);
  opacity: 0;
  transition: opacity 0.3s;
  text-shadow: 0 0 8px rgba(0, 0, 0, 0.9);
  pointer-events: none;
  z-index: 2;
}

.char-card:hover::after {
  opacity: 0.9;
}

.char-footnote {
  text-align: center;
  margin-top: 2.5rem;
  font-size: 0.85rem;
  color: var(--text-dim);
  font-style: italic;
  letter-spacing: 1px;
}

.char-footnote a {
  color: var(--gold-dim);
  text-decoration: none;
}

@media (max-width: 900px) {
  .char-grid {
    grid-template-columns: 1fr 1fr;
    gap: 1.2rem;
    min-height: calc((min(100vw, 1100px) / 2) * (4/3) * 3);
  }
}

@media (max-width: 600px) {
  .char-grid {
    grid-template-columns: 1fr;
    gap: 1.2rem;
    min-height: auto;
  }
}

/* Static crawlable character index (fallback shown when JS hasn't replaced the grid).
   Styled so no-JS visitors and crawlers still get a tidy, on-brand list. */
.char-index {
  grid-column: 1 / -1;
  list-style: none;
  max-width: 700px;
  margin: 0 auto;
  padding: 0;
  text-align: left;
}
.char-index li {
  padding: 0.9rem 0;
  border-bottom: 1px solid var(--border);
  color: var(--text-dim);
}
.char-index li:last-child { border-bottom: none; }
.char-index a {
  font-family: 'Cinzel', serif;
  font-size: 1rem;
  letter-spacing: 1px;
  color: var(--gold-light);
  text-decoration: none;
  transition: color 0.3s;
}
.char-index a:hover { color: var(--gold); }
