/* ════════════════════════════════════════════
   Chronicles — Dark Cosmic Design
   Uses variables from style.css:
   --bg, --bg-alt, --bg-card, --text, --text-muted,
   --accent, --accent-glow, --warm, --warm-glow,
   --cyan, --cyan-glow, --border, --border-hover
   ════════════════════════════════════════════ */

/* ── Shared Page Layout ── */
.chronicles-page {
  padding-top: 5rem;
}

.chronicles-hero-banner {
  text-align: center;
  padding: 6rem 2rem 4rem;
  position: relative;
  overflow: hidden;
}

.chronicles-hero-banner::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at 40% 60%, var(--accent-glow) 0%, transparent 60%),
              radial-gradient(ellipse at 70% 30%, var(--warm-glow) 0%, transparent 50%);
  pointer-events: none;
}

.chronicles-hero-banner .section-inner {
  position: relative;
  z-index: 1;
}

.chronicles-hero-banner h1 {
  font-size: clamp(2rem, 5vw, 3.5rem);
  font-weight: 800;
  letter-spacing: -0.03em;
  margin-bottom: 1rem;
  line-height: 1.15;
}

.chronicles-hero-banner h1 .highlight {
  background: linear-gradient(135deg, var(--accent), var(--warm));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.chronicles-hero-banner .section-desc {
  font-size: 1.15rem;
  color: var(--text-muted);
  max-width: 640px;
  margin: 0 auto;
  line-height: 1.8;
}

.chronicles-back {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  color: var(--text-muted);
  font-size: 0.85rem;
  font-weight: 500;
  margin-bottom: 1.5rem;
}

.chronicles-back:hover {
  color: var(--accent);
}

/* ── Explore Cards (bottom nav) ── */
.explore-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.5rem;
  max-width: 900px;
  margin: 0 auto;
}

.explore-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 2.5rem 2rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  transition: border-color 0.3s, transform 0.3s;
  color: var(--text);
}

.explore-card:hover {
  border-color: var(--border-hover);
  transform: translateY(-3px);
  color: var(--text);
}

.explore-card-icon {
  font-size: 2rem;
  margin-bottom: 1rem;
  color: var(--accent);
}

.explore-card h3 {
  font-size: 1.05rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
}

.explore-card p {
  color: var(--text-muted);
  font-size: 0.88rem;
  line-height: 1.6;
}

/* ── Character Grid ── */
.character-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1.5rem;
  margin-top: 2rem;
}

/* Legacy card styles kept for compatibility */
.character-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  overflow: hidden;
  transition: border-color 0.3s, transform 0.3s;
  color: var(--text);
  display: block;
}

.character-card:hover {
  border-color: var(--border-hover);
  transform: translateY(-3px);
  color: var(--text);
}

.character-card-top {
  height: 4px;
}

.character-card-body {
  padding: 1.8rem 1.5rem 1.5rem;
}

.character-card-avatar {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  font-weight: 800;
  color: white;
  margin-bottom: 1rem;
  overflow: hidden;
}

.character-card-avatar img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
  object-position: top;
}

.character-card h3 {
  font-size: 1.15rem;
  font-weight: 700;
  margin-bottom: 0.2rem;
}

.character-card .character-role {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.8rem;
}

.character-card p {
  color: var(--text-muted);
  font-size: 0.9rem;
  line-height: 1.7;
  margin-bottom: 1rem;
}

.character-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.character-badge {
  display: inline-block;
  padding: 0.2rem 0.6rem;
  font-size: 0.7rem;
  font-weight: 600;
  border-radius: 50px;
  letter-spacing: 0.02em;
  color: white;
}

.character-card-link {
  text-decoration: none;
  color: inherit;
  display: block;
}

.character-genre {
  display: inline-block;
  padding: 0.15rem 0.55rem;
  font-size: 0.65rem;
  font-weight: 600;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 0.6rem;
}

/* ── Character Tile (portrait-wall mosaic) ── */
.character-tile {
  position: relative;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  overflow: hidden;
  transition: border-color 0.3s, transform 0.3s;
  color: var(--text);
  border-bottom: 3px solid;
}

.character-tile:hover {
  border-color: var(--border-hover);
  transform: translateY(-3px);
}

.character-tile-portrait {
  width: 100%;
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  border-bottom: 3px solid;
}

.character-tile-portrait img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: top;
}

.character-tile-info {
  padding: 1.2rem 1rem 1rem;
  text-align: center;
}

.character-tile-info h3 {
  font-size: 1.15rem;
  font-weight: 700;
  margin-bottom: 0.2rem;
}

.character-tile-info .character-role {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.5rem;
}

.character-tile-info .character-genre {
  margin-bottom: 0;
}

.character-tile-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  opacity: 0;
  transition: opacity 0.3s;
  color: white;
  text-align: center;
  pointer-events: none;
}

.character-tile:hover .character-tile-overlay {
  opacity: 0.92;
}

.character-tile-overlay p {
  font-size: 0.95rem;
  line-height: 1.6;
  margin-bottom: 0.6rem;
}

.character-tile-overlay .character-genre {
  margin-bottom: 0;
}

/* ── Character-specific detail page effects ── */
.character-portrait {
  position: relative;
  display: inline-block;
}

/* Synthax — Sacred geometry overlay */
.character-portrait--synthax::before {
  content: '';
  position: absolute;
  inset: -15%;
  border: 1px dashed rgba(124, 108, 240, 0.25);
  border-radius: 50%;
  animation: synthax-rotate 24s linear infinite;
  pointer-events: none;
  z-index: 0;
}

@keyframes synthax-rotate {
  to { transform: rotate(360deg); }
}

/* APEX — Neon glitch on h1 hover */
.character-portrait--apex + .character-detail-header h1:hover {
  text-shadow: -2px 0 rgba(96, 200, 208, 0.85), 2px 0 rgba(245, 0, 155, 0.7);
}

/* Finny — Pixel-stipple border */
.character-portrait--finny {
  background: repeating-linear-gradient(45deg, #10B981 0, #10B981 2px, transparent 2px, transparent 4px);
  padding: 3px;
}

/* Mentor — Parchment drop shadow + warm sepia inner glow */
.character-portrait--mentor {
  box-shadow: 0 14px 36px rgba(45, 106, 79, 0.25), inset 0 0 30px rgba(194, 160, 90, 0.1);
  border-radius: 12px;
}

.character-portrait--mentor img {
  filter: sepia(0.12) saturate(0.9);
}

/* Daedalus — Blueprint grid overlay */
.character-portrait--daedalus::after {
  content: '';
  position: absolute;
  inset: 0;
  background-image: repeating-linear-gradient(0deg, transparent, transparent 19px, rgba(74, 111, 165, 0.12) 20px),
                    repeating-linear-gradient(90deg, transparent, transparent 19px, rgba(74, 111, 165, 0.12) 20px);
  pointer-events: none;
  border-radius: inherit;
}

/* Sentinel — Radar sweep */
.character-portrait--sentinel::before {
  content: '';
  position: absolute;
  inset: 0;
  background: conic-gradient(from 0deg, transparent 0deg, rgba(79, 70, 229, 0.12) 50deg, transparent 100deg);
  animation: sentinel-sweep 5s linear infinite;
  pointer-events: none;
  z-index: 1;
  border-radius: inherit;
}

@keyframes sentinel-sweep {
  to { transform: rotate(360deg); }
}

/* Hawk — Red diagonal corner stripes */
.character-portrait--hawk::before,
.character-portrait--hawk::after {
  content: '';
  position: absolute;
  width: 36px;
  height: 36px;
  pointer-events: none;
  z-index: 2;
}

.character-portrait--hawk::before {
  top: 0;
  left: 0;
  background: linear-gradient(135deg, #EF4444 50%, transparent 50%);
}

.character-portrait--hawk::after {
  bottom: 0;
  right: 0;
  background: linear-gradient(315deg, #EF4444 50%, transparent 50%);
}

/* Darwin — Earthy paper-grain + leaf glyphs */
.character-portrait--darwin {
  background: repeating-linear-gradient(0deg, rgba(180, 83, 9, 0.04), rgba(180, 83, 9, 0.04) 1px, transparent 1px, transparent 4px);
}

.character-portrait--darwin::before,
.character-portrait--darwin::after {
  content: '🍃';
  position: absolute;
  font-size: 1.3rem;
  pointer-events: none;
  z-index: 2;
  filter: drop-shadow(0 2px 3px rgba(180, 83, 9, 0.25));
}

.character-portrait--darwin::before {
  top: -6px;
  left: -6px;
}

.character-portrait--darwin::after {
  bottom: -6px;
  right: -6px;
  transform: scaleX(-1);
}

/* Quill — CRT scanlines + amber phosphor glow */
.character-portrait--quill {
  box-shadow: 0 0 28px rgba(245, 158, 11, 0.18);
}

.character-portrait--quill::before {
  content: '';
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(0deg, transparent, transparent 2px, rgba(245, 158, 11, 0.08) 2px, rgba(245, 158, 11, 0.08) 4px);
  pointer-events: none;
  z-index: 2;
  border-radius: inherit;
}

/* RECALL — Ledger rule lines */
.character-portrait--recall::before {
  content: '';
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(0deg, transparent, transparent 21px, rgba(139, 92, 246, 0.10) 21px, rgba(139, 92, 246, 0.10) 22px);
  pointer-events: none;
  z-index: 2;
  border-radius: inherit;
}

/* ── Story Grid ── */
.story-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.5rem;
  margin-top: 2rem;
}

.story-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 1.8rem 1.5rem;
  transition: border-color 0.3s, transform 0.3s;
  display: flex;
  flex-direction: column;
}

.story-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
}

.story-card h3 {
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 0.8rem;
}

.story-card .story-excerpt {
  color: var(--text-muted);
  font-size: 0.9rem;
  line-height: 1.7;
  flex: 1;
  margin-bottom: 1rem;
}

.story-card .story-characters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: auto;
}

/* ── Filter Pills ── */
.filter-pills {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  justify-content: center;
  margin-bottom: 2.5rem;
}

.filter-pill {
  display: inline-block;
  padding: 0.5rem 1.2rem;
  font-size: 0.85rem;
  font-weight: 600;
  border: 1px solid var(--border);
  border-radius: 50px;
  background: var(--bg-card);
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.2s;
  font-family: inherit;
}

.filter-pill:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.filter-pill.is-active {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}

/* ── Timeline ── */
.timeline {
  position: relative;
  max-width: 720px;
  margin: 0 auto;
  padding: 2rem 0;
}

.timeline::before {
  content: '';
  position: absolute;
  top: 0;
  bottom: 0;
  left: 28px;
  width: 2px;
  background: rgba(255, 255, 255, 0.06);
}

.timeline-entry {
  position: relative;
  padding-left: 72px;
  padding-bottom: 3rem;
}

.timeline-entry:last-child {
  padding-bottom: 0;
}

.timeline-dot {
  position: absolute;
  left: 20px;
  top: 4px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--accent);
  border: 3px solid var(--bg);
  box-shadow: 0 0 0 2px var(--accent), 0 0 12px var(--accent-glow);
  z-index: 1;
}

.timeline-dot.future {
  background: var(--bg);
  border-color: var(--warm);
  box-shadow: 0 0 0 2px var(--warm), 0 0 16px var(--warm-glow);
}

.timeline-date {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.4rem;
}

.timeline-entry h3 {
  font-size: 1.2rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
}

.timeline-entry p {
  color: var(--text-muted);
  font-size: 0.93rem;
  line-height: 1.7;
}

/* ── Live Chronicles Feed (rendered cards + detail view) ── */

/* Ensure [hidden] wins over the display rules on grids / pills / sections
   so the list<->detail view toggle works reliably. */
[hidden] {
  display: none !important;
}

/* Full-width status / loading / empty message inside the story grid */
.story-status {
  grid-column: 1 / -1;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.95rem;
  line-height: 1.7;
  padding: 2.5rem 1rem;
}

/* Feed cards are clickable links; let the image bleed to the card edge */
a.story-card {
  padding: 0;
  overflow: hidden;
  color: var(--text);
  text-decoration: none;
}

.story-card-img {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  background: var(--bg-alt);
}

.story-card-img img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.4s ease;
}

a.story-card:hover .story-card-img img {
  transform: scale(1.04);
}

.story-card-body {
  padding: 1.4rem 1.5rem 1.5rem;
  display: flex;
  flex-direction: column;
  flex: 1;
}

.story-card-date {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.5rem;
}

/* ── Story Detail View ── */
.story-detail {
  max-width: 760px;
  margin: 0 auto;
}

.story-detail .chronicles-back {
  margin-bottom: 0.5rem;
}

.story-detail-media {
  margin: 1.25rem 0 2rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.story-detail-media img {
  width: 100%;
  display: block;
}

.story-detail-header {
  text-align: center;
  margin-bottom: 1.75rem;
}

.story-detail-header h1 {
  font-size: clamp(1.8rem, 4vw, 2.6rem);
  font-weight: 800;
  letter-spacing: -0.02em;
  margin-bottom: 0.5rem;
}

.story-detail-date {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 1rem;
}

.story-detail-chars {
  display: flex;
  justify-content: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.story-detail audio {
  width: 100%;
  display: block;
  margin: 0 0 2rem;
}

.story-detail-body p {
  color: var(--text);
  font-size: 1.05rem;
  line-height: 1.85;
  margin-bottom: 1.2rem;
}

/* ════════════════════════════════════════════
   RESPONSIVE — Chronicles
   ════════════════════════════════════════════ */

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

  .explore-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 768px) {
  .chronicles-hero-banner {
    padding: 4rem 1.5rem 2.5rem;
  }

  .character-grid,
  .story-grid,
  .explore-grid {
    grid-template-columns: 1fr;
    max-width: 480px;
    margin-left: auto;
    margin-right: auto;
  }

  .filter-pills {
    justify-content: flex-start;
    overflow-x: auto;
    flex-wrap: nowrap;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding-bottom: 0.5rem;
  }

  .filter-pills::-webkit-scrollbar {
    display: none;
  }

  .filter-pill {
    flex-shrink: 0;
  }

  .timeline::before {
    left: 20px;
  }

  .timeline-dot {
    left: 12px;
    width: 16px;
    height: 16px;
  }

  .timeline-entry {
    padding-left: 52px;
    padding-bottom: 2.5rem;
  }
}
