/* ==========================================================================
   PITBORN — world.css
   The World hall (views/world.js) and the Chronicle (views/chronicle.js), layered on app.css
   (tokens, .panel, .btn, .badge, .stat-strip, .chronicle/.entry, .table live there).
   Sections: 1 world head & controls · 2 new-world form · 3 stats strip · 4 season report ·
   5 top tables · 6 saved worlds · 7 watch mode · 8 chronicle filters · 9 chronicle feed ·
   10 responsive · 11 motion
   ========================================================================== */

/* 1. World head & controls -------------------------------------------------- */
.world-head .sub code { color: var(--gold-bright); background: none; padding: 0; }
.world-title { color: var(--gold-bright); }
.world-controls {
  padding: 10px 12px; margin-bottom: 14px;
  background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--radius-lg);
}
.world-controls .btn.on, .watch-controls .btn[aria-pressed="true"] { color: var(--gold-bright); border-color: var(--gold-dim); box-shadow: var(--glow-gold); }
.world-speed-wrap { gap: 6px; }
.world-sim-status { white-space: nowrap; }
a.dead { color: var(--text-muted); }
a.dead::after { content: " †"; color: var(--blood-bright); font-size: 0.8em; }

/* 2. New-world form --------------------------------------------------------- */
.world-hero { max-width: 900px; margin: 2vh auto 18px; padding: 32px 28px 26px; }
.world-hero .eyebrow, .world-hero h1 { text-align: center; }
.world-hero h1 { color: var(--gold-bright); }
.world-hero .lede { text-align: center; max-width: 54ch; margin: 0 auto 22px; font-size: 1.05rem; }
.nw-form .field { margin-bottom: 8px; }
.nw-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 4px 20px; }
.nw-field-cultures { grid-column: 1 / -1; }
.nw-field-pop .field-row input[type="range"] { flex: 1 1 auto; min-width: 120px; }
.input.num { width: 5.5em; flex: 0 0 auto; text-align: right; font-variant-numeric: tabular-nums; }
.nw-cultures { padding: 8px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--bg-1); }
.nw-cultures .chip[aria-pressed="false"] { opacity: 0.5; }
.nw-cultures .chip[aria-pressed="false"]:hover { opacity: 0.85; }
.nw-chip-all { font-weight: 700; }
.nw-lethality .btn { min-width: 84px; }
.nw-summary { margin: 4px 0 12px; font-family: var(--font-mono); font-size: 0.74rem; line-height: 1.5; }
.nw-actions { gap: 12px; }
.nw-modal .nw-grid { gap: 0 16px; }
.nw-modal .world-hero { margin: 0; padding: 0; }

/* 3. Stats strip ------------------------------------------------------------ */
.world-stats { margin-bottom: var(--gap); }
.world-stats .stat-tile { flex: 1 1 128px; }
.world-stats .stat-tile[data-stat="date"] { flex: 1.8 1 220px; }
.world-stats .v.date { font-size: 1.2rem; color: var(--parchment); }
.world-stats .v.tick { animation: stat-tick 420ms var(--ease); }
@keyframes stat-tick { from { color: #fff8e6; transform: translateY(-2px); } }

/* 4. Season report ---------------------------------------------------------- */
.world-report { margin-bottom: var(--gap); }
.report-counts { margin-bottom: 12px; gap: 6px; }
.report-counts .chip { cursor: default; }
.report-counts .chip b { color: var(--gold-bright); font-family: var(--font-display); font-size: 0.95rem; margin-right: 3px; }
.report-counts .chip.blood b { color: var(--blood-bright); }
.report-grid { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 18px 24px; }
.report-grid h3, .report-headlines h3 { font-size: 0.66rem; margin: 0 0 6px; letter-spacing: 0.16em; }
.report-event-list { list-style: none; margin: 0; padding: 0; }
.report-event { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; padding: 7px 0; border-bottom: 1px dashed var(--line-soft); font-size: 0.86rem; }
.report-event:last-child { border-bottom: 0; }
.report-event-name { font-family: var(--font-display); font-size: 1.02rem; color: var(--parchment); }
.report-event-champ { margin-left: auto; color: var(--text-muted); font-size: 0.82rem; }
.report-event-champ a { color: var(--gold-bright); }
.report-lists { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 14px; }
.report-list ul { list-style: none; margin: 0; padding: 0; font-size: 0.84rem; }
.report-list li { padding: 2px 0; border-bottom: 1px dashed var(--line-soft); overflow-wrap: anywhere; }
.report-list li:last-child { border-bottom: 0; }
.report-list p { margin: 0; }
.report-headlines { margin-top: 18px; }
.report-headlines .chronicle { gap: 6px; margin-bottom: 8px; }
.report-headlines .entry { padding: 8px 12px 8px 14px; }
.report-headlines .entry.w2 .entry-title { font-size: 1.08rem; }
.report-headlines .entry-text { font-size: 0.86rem; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.report-actions { justify-content: flex-end; }

/* 5. Top tables ------------------------------------------------------------- */
.world-tops { margin-bottom: var(--gap); }
.world-tops .panel { min-width: 0; }
.world-tops .table-wrap { overflow-x: auto; }
.world-tops .table td.name a { color: var(--parchment); }
.house-cell { display: inline-flex; align-items: center; gap: 8px; }
.house-cell .sigil { flex: none; }

/* 6. Saved worlds ----------------------------------------------------------- */
.saved-list { list-style: none; margin: 0; padding: 0; }
.saved-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; padding: 10px 8px; margin: 0 -8px; border-bottom: 1px solid var(--line-soft); border-radius: var(--radius); }
.saved-row:last-child { border-bottom: 0; }
.saved-row.current { background: rgba(224, 164, 88, 0.06); }
.saved-main { flex: 1 1 320px; min-width: 0; }
.saved-name { font-size: 1.05rem; color: var(--parchment); display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.saved-meta { overflow-wrap: anywhere; }
.saved-meta code { color: var(--gold); background: none; padding: 0; }
.saved-actions { flex: none; gap: 4px; }

/* 7. Watch mode ------------------------------------------------------------- */
body.watch-open { overflow: hidden; }
.watch-mode {
  position: fixed; inset: 0; z-index: 60;
  display: flex; flex-direction: column;
  background:
    radial-gradient(ellipse 80% 50% at 50% -10%, rgba(217, 116, 42, 0.16), transparent 70%),
    var(--bg-0);
  color: var(--text);
  animation: watch-in var(--t) var(--ease);
}
.watch-head {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 20px;
  padding: 12px var(--gap) 10px;
  border-bottom: 1px solid var(--line-strong);
  background: linear-gradient(180deg, #1a1411, #110d0b);
  position: relative;
}
.watch-head::before {
  content: ""; position: absolute; left: 0; right: 0; top: 0; height: 2px;
  background: linear-gradient(90deg, transparent 0%, var(--ember) 25%, var(--gold-bright) 50%, var(--ember) 75%, transparent 100%);
}
.watch-titles { min-width: 0; }
.watch-titles .eyebrow { margin-bottom: 0; }
.watch-world { margin: 0 0 2px; font-size: clamp(1.3rem, 2.6vw, 1.9rem); color: var(--gold-bright); font-style: italic; font-weight: 400; line-height: 1.15; }
.watch-mode.running .watch-world::after {
  content: ""; display: inline-block; width: 8px; height: 8px; margin-left: 10px; border-radius: 50%;
  background: var(--gold-bright); box-shadow: 0 0 10px var(--gold); vertical-align: middle;
  animation: pulse 1.2s ease-in-out infinite;
}
.watch-date { color: var(--gold); }
.watch-controls { gap: 6px; }
.watch-controls kbd { margin-left: 4px; }
.watch-feed {
  flex: 1 1 auto; overflow-y: auto; overscroll-behavior: contain;
  width: 100%; max-width: 1100px; margin: 0 auto;
  padding: 16px var(--gap) 40px;
  display: flex; flex-direction: column; gap: 10px;
}
.watch-item {
  display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 14px;
  padding: 12px 16px;
  border: 1px solid var(--line); border-left: 3px solid var(--line-strong); border-radius: var(--radius-lg);
  background: var(--bg-2);
}
.watch-item.fresh { animation: watch-item-in 700ms var(--ease); }
.watch-item.w2 { border-left-color: var(--ember); background: rgba(217, 116, 42, 0.06); }
.watch-item.w3 { border-left-color: var(--gold); background: linear-gradient(180deg, var(--parchment-bg-2), var(--parchment-bg)); box-shadow: var(--glow-gold); }
.watch-item.kind-death_bout, .watch-item.kind-death_wound, .watch-item.kind-death_illness, .watch-item.kind-death_age, .watch-item.kind-plagueSeason, .watch-item.kind-arenaFire { border-left-color: var(--blood); }
.watch-item.kind-legendInducted { border-left-color: var(--ember-hot); }
.watch-thumbs { display: flex; gap: 6px; align-items: flex-start; min-width: 56px; }
.watch-thumb {
  display: inline-flex; align-items: center; justify-content: center;
  width: 54px; min-height: 64px; border-radius: var(--radius);
  background: var(--bg-1); border: 1px solid var(--line-soft); overflow: hidden;
  color: var(--text-faint); font-size: 1.2rem;
}
.watch-thumb svg { width: 54px; height: auto; display: block; }
.watch-thumb.dead { filter: grayscale(1) brightness(0.7); }
.watch-thumb.ward { font-size: 1.6rem; color: var(--parchment-soft); }
.watch-thumb.sigil { width: 34px; min-height: 40px; height: auto; padding: 3px; }
.watch-thumb.sigil svg { width: 26px; }
.watch-body { min-width: 0; }
.watch-stars { font-size: 0.7rem; letter-spacing: 0.1em; }
.watch-title { margin: 2px 0 4px; font-family: var(--font-display); font-size: 1.2rem; color: var(--text-strong); line-height: 1.2; }
.watch-item.w3 .watch-title { font-size: 1.5rem; }
.watch-text { margin: 0; color: var(--parchment); opacity: 0.9; font-size: 0.95rem; line-height: 1.55; }
.watch-links { margin-top: 6px; font-size: 0.8rem; color: var(--text-muted); }
.watch-links a { color: var(--gold-bright); }
.watch-foot { text-align: center; padding: 8px var(--gap) calc(8px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); }
.watch-empty { padding: 48px 16px; }
@keyframes watch-in { from { opacity: 0; } }
@keyframes watch-item-in { from { opacity: 0; transform: translateY(-10px); background: rgba(245, 207, 133, 0.18); } }

/* 8. Chronicle filters ------------------------------------------------------ */
.chronicle-filters {
  display: flex; flex-direction: column; gap: 8px;
  margin-bottom: 14px; padding: 10px 12px;
  background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--radius-lg);
}
.chronicle-filters .row { gap: 8px; }
.chronicle-filters .select { max-width: 240px; }
.chronicle-filters .search-wrap { flex: 1 1 200px; }
.chronicle-filters .btn.on { color: var(--gold-bright); border-color: var(--gold-dim); }
.chronicle-filters .btn .count { font-size: 0.64rem; padding: 0 5px; border-radius: 999px; background: var(--bg-5); color: var(--text-muted); line-height: 1.5; }
.chronicle-count { white-space: nowrap; }

/* 9. Chronicle feed --------------------------------------------------------- */
.chronicle-view .chronicle-feed .entry { content-visibility: auto; contain-intrinsic-size: auto 104px; }
.chronicle-view .chronicle-feed .entry.w0 { contain-intrinsic-size: auto 64px; }
.chronicle-view .chronicle-feed .entry.w3 { contain-intrinsic-size: auto 220px; }
.entry.fresh { animation: entry-in 900ms var(--ease); }
@keyframes entry-in { from { background: rgba(245, 207, 133, 0.16); transform: translateY(-4px); } }
.entry.archived { opacity: 0.6; }
.entry-weight { color: var(--gold); font-size: 0.68rem; letter-spacing: 0.12em; }
.entry-text a.ref-fighter { color: var(--gold-bright); text-decoration: underline dotted rgba(224, 164, 88, 0.55); text-underline-offset: 2px; }
.entry-text a.ref-fighter.dead { color: var(--parchment-soft); }
.entry-text a.ref-house { color: var(--ember-hot); text-decoration: underline dotted rgba(255, 143, 58, 0.55); text-underline-offset: 2px; }
/* ref badges carry whole display names: let them wrap instead of pushing the page wider */
.entry-refs .badge { white-space: normal; text-align: left; max-width: 100%; overflow-wrap: anywhere; }
.entry-refs .badge.ref { display: inline-flex; align-items: center; gap: 4px; padding-right: 5px; }
.entry-refs .badge.ref a { color: inherit; }
.entry-refs .badge.ref.dead a::after { content: " †"; color: var(--blood-bright); }
.entry-refs .badge.ref.house { border-color: rgba(255, 143, 58, 0.4); color: var(--parchment); }
.entry-refs .badge.ref.event { color: #b6c8dc; border-color: #4a5f78; }
.entry-refs .badge.ref.bout { color: var(--parchment); }
.entry-follow { border: 0; background: transparent; color: var(--text-faint); padding: 0 2px; cursor: pointer; display: inline-flex; line-height: 1; border-radius: 50%; }
.entry-follow:hover, .entry-follow.on { color: var(--gold-bright); }
.entry-follow .ico { width: 12px; height: 12px; }
.chronicle-sentinel { text-align: center; padding: 14px; color: var(--text-faint); font-size: 0.78rem; font-style: italic; font-family: var(--font-display); }
.chronicle-new { position: sticky; top: 10px; z-index: 5; margin: 0 auto 10px; display: flex; box-shadow: var(--shadow); }
.chronicle-foot { justify-content: center; margin-top: 12px; }

/* 10. Responsive ------------------------------------------------------------ */
@media (max-width: 1100px) {
  .report-grid { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 960px) {
  .world-tops { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 720px) {
  .nw-grid { grid-template-columns: minmax(0, 1fr); }
  .world-hero { padding: 22px 14px 18px; }
  .report-lists { grid-template-columns: minmax(0, 1fr); }
  .report-event-champ { margin-left: 0; width: 100%; }
  .world-controls .world-sim-status { width: 100%; white-space: normal; }
  .world-stats .stat-tile { flex: 1 1 42%; }
  .world-stats .stat-tile[data-stat="date"] { flex: 1 1 100%; }
  .saved-actions { width: 100%; }
  .watch-head { padding: 10px var(--gap); }
  .watch-world { font-size: 1.2rem; }
  .watch-item { grid-template-columns: minmax(0, 1fr); gap: 8px; padding: 10px 12px; }
  .watch-thumbs { order: 2; }
  .watch-thumb { width: 40px; min-height: 48px; }
  .watch-thumb svg { width: 40px; }
  .watch-item.w3 .watch-title { font-size: 1.25rem; }
  .chronicle-filters .select { max-width: 100%; flex: 1 1 140px; }
  .chronicle-filters .search-wrap { flex-basis: 100%; }
  .chronicle-count { white-space: normal; }
}

/* 11. Motion ---------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  .world-stats .v.tick, .watch-mode, .watch-item.fresh, .entry.fresh, .watch-mode.running .watch-world::after { animation: none !important; }
  .watch-feed { scroll-behavior: auto; }
}
