/* =========================================================
   Career: chapter rail + event cards, results objectives,
   championship tables and the Legend ending
   ========================================================= */

.panel-career {
  width: min(1180px, 100%);
  height: 100%;
}

.career-summary {
  display: flex;
  gap: 18px;
  text-align: right;
}

.career-summary span {
  display: block;
  font-size: 11px;
  letter-spacing: 0.26em;
  color: var(--text-dim);
}

.career-summary strong {
  font-family: var(--font-display);
  font-size: 18px;
  color: var(--electric);
  font-variant-numeric: tabular-nums;
}

.career-body {
  display: grid;
  grid-template-columns: 250px 1fr;
  min-height: 0;
  flex: 1;
}

/* ---------- Chapter rail ---------- */
.chapter-rail {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 16px;
  border-right: 1px solid var(--line);
  overflow-y: auto;
}

.chapter-btn {
  display: grid;
  gap: 3px;
  padding: 11px 12px;
  text-align: left;
  border: 1px solid transparent;
  border-left: 3px solid var(--line-strong);
  background: rgba(20, 28, 70, 0.25);
  transition: background var(--t-fast), border-color var(--t-fast);
  outline: none;
}

.chapter-btn:hover:not([disabled]),
.chapter-btn:focus-visible {
  background: rgba(47, 123, 255, 0.14);
}

.chapter-btn.active {
  border-color: var(--line-strong);
  border-left-color: var(--electric);
  background: rgba(47, 123, 255, 0.18);
}

.chapter-btn.complete {
  border-left-color: #52e0a0;
}

.chapter-btn.active.complete {
  border-left-color: var(--electric);
}

.chapter-btn.locked {
  opacity: 0.45;
  cursor: not-allowed;
}

.chapter-num {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.26em;
  color: var(--purple);
}

.chapter-name {
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.06em;
}

.chapter-meta {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.08em;
  color: var(--text-dim);
}

.chapter-bar {
  height: 3px;
  margin-top: 4px;
  background: rgba(120, 140, 255, 0.15);
}

.chapter-bar i {
  display: block;
  height: 100%;
  background: var(--grad-accent);
}

/* ---------- Chapter detail ---------- */
.chapter-detail {
  min-width: 0;
  padding: 18px 22px 22px;
  overflow-y: auto;
  touch-action: pan-y;
}

.chapter-hero {
  margin-bottom: 16px;
}

.chapter-kicker {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.3em;
  color: var(--electric);
}

.chapter-title {
  margin: 2px 0 6px;
  font-family: var(--font-display);
  font-weight: 900;
  font-size: clamp(24px, 3vw, 34px);
  letter-spacing: 0.08em;
}

.chapter-blurb {
  max-width: 68ch;
  margin: 0 0 10px;
  font-size: 15px;
  line-height: 1.45;
  color: var(--text-dim);
}

.chapter-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chapter-tags span {
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.12em;
  color: var(--text-dim);
  border: 1px solid var(--line);
}

.chapter-tags b {
  color: var(--gold);
}

.event-list {
  display: grid;
  gap: 12px;
}

.career-event {
  display: grid;
  gap: 8px;
  padding: 14px 16px;
  background: linear-gradient(160deg, rgba(30, 44, 120, 0.38), rgba(12, 16, 44, 0.6));
  border: 1px solid var(--line);
}

.career-event.done {
  border-left: 3px solid #52e0a0;
}

.career-event.locked {
  opacity: 0.5;
}

.career-event header {
  display: flex;
  align-items: center;
  gap: 12px;
}

.event-index {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 900;
  color: var(--text-faint);
}

.event-head {
  flex: 1;
  min-width: 0;
}

.event-type {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.24em;
  color: var(--purple);
}

.event-type.champ {
  color: var(--gold);
}

.career-event h4 {
  margin: 1px 0 0;
  font-family: var(--font-display);
  font-size: 18px;
  letter-spacing: 0.06em;
}

.event-status {
  font-family: var(--font-display);
  font-size: 11px;
  letter-spacing: 0.16em;
  padding: 3px 8px;
  border: 1px solid var(--line-strong);
  color: var(--text-dim);
}

.career-event.done .event-status {
  color: #52e0a0;
  border-color: rgba(82, 224, 160, 0.5);
}

.career-event .event-desc {
  margin: 0;
  font-size: 14px;
  color: var(--text-dim);
}

.event-facts {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: var(--text);
}

.event-facts .warn,
.event-lock-note.warn {
  color: var(--gold);
}

.objective-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 4px;
}

.objective-list li {
  display: grid;
  grid-template-columns: 18px 1fr auto;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  color: var(--text-dim);
}

.objective-list li i {
  font-style: normal;
  color: var(--text-faint);
}

.objective-list li.ok {
  color: var(--text);
}

.objective-list li.ok i {
  color: var(--gold);
  text-shadow: 0 0 8px rgba(255, 204, 77, 0.7);
}

.objective-list li em {
  font-style: normal;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--text-faint);
}

.objective-list li.ok em {
  color: #52e0a0;
}

.objective-list li.new em {
  color: var(--gold);
}

.champ-progress {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 7px 10px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.14em;
  color: var(--gold);
  border: 1px dashed rgba(255, 204, 77, 0.5);
}

.link-btn {
  font-size: 11px;
  letter-spacing: 0.16em;
  color: var(--text-dim);
  text-decoration: underline;
}

.event-actions {
  display: flex;
  justify-content: flex-end;
}

.event-go {
  width: auto;
  padding: 11px 22px;
  font-size: 13px;
}

.event-lock-note {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-dim);
}

/* ---------- Results: objectives + championship ---------- */
.results-section-title {
  margin: 4px 0 6px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.26em;
  text-align: left;
  color: var(--text-dim);
}

.results-objectives,
.results-champ {
  margin-bottom: 12px;
  text-align: left;
}

.champ-table {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 2px;
}

.champ-table li {
  display: grid;
  grid-template-columns: 22px auto 1fr auto;
  align-items: center;
  gap: 8px;
  padding: 5px 8px;
  font-size: 14px;
  border-bottom: 1px solid var(--line);
}

.champ-table li.me {
  background: rgba(47, 123, 255, 0.16);
  color: #fff;
}

.champ-table b {
  font-family: var(--font-display);
}

.champ-table strong {
  font-family: var(--font-display);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

.champ-table .swatch-dot,
.results-table .swatch-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.results-table td.pts {
  color: var(--gold);
  font-weight: 700;
}

.results-targets b {
  color: var(--gold);
}

/* ---------- Legend ending ---------- */
.screen-legend {
  z-index: 60;
  background: radial-gradient(ellipse at 50% 30%, rgba(155, 77, 255, 0.35), rgba(3, 4, 12, 0.92) 65%);
}

.legend-box {
  width: min(560px, 100%);
  max-height: 100%;
  overflow-y: auto;
  padding: 28px 24px;
  text-align: center;
}

.legend-kicker {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.4em;
  color: var(--gold);
}

.legend-title {
  margin: 6px 0 12px;
  font-family: var(--font-display);
  font-weight: 900;
  font-style: italic;
  font-size: clamp(56px, 14vw, 110px);
  line-height: 1;
  padding: 0 0.1em;
  background: linear-gradient(180deg, #fff4c2, #ffcc4d 55%, #ff7a2e);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 0 24px rgba(255, 180, 60, 0.5));
}

.screen-legend.active .legend-title {
  animation: legend-in 1.2s var(--ease-out);
}

@keyframes legend-in {
  from { transform: scale(1.6); opacity: 0; letter-spacing: 0.4em; }
  to { transform: none; opacity: 1; }
}

.legend-text,
.legend-note {
  margin: 0 auto 16px;
  max-width: 46ch;
  font-size: 16px;
  line-height: 1.5;
  color: var(--text-dim);
}

.legend-note {
  font-size: 14px;
}

.legend-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-bottom: 16px;
}

.legend-stats div {
  padding: 10px 6px;
  border: 1px solid var(--line);
  background: rgba(20, 28, 70, 0.45);
}

.legend-stats span {
  display: block;
  font-size: 10px;
  letter-spacing: 0.24em;
  color: var(--text-dim);
}

.legend-stats strong {
  font-family: var(--font-display);
  font-size: 17px;
}

/* ---------- Responsive ---------- */
@media (max-width: 760px) {
  .career-body {
    grid-template-columns: 1fr;
    overflow-y: auto;
  }
  .chapter-rail {
    flex-direction: row;
    overflow-x: auto;
    overflow-y: visible;
    border-right: 0;
    border-bottom: 1px solid var(--line);
    padding: 10px 12px;
    touch-action: pan-x;
  }
  .chapter-btn { flex: 0 0 170px; }
  .chapter-detail { overflow: visible; padding: 14px 16px 18px; }
  .career-summary { gap: 10px; }
  .career-summary > div:last-child { display: none; }
  .legend-stats { grid-template-columns: repeat(2, 1fr); }
}

/* Fixes: legend title fits; result buttons stay reachable on tall results */
.legend-title {
  font-size: clamp(44px, 10vw, 84px);
  letter-spacing: 0.02em;
  overflow: visible;
}

.results-box .overlay-nav {
  position: sticky;
  bottom: -20px;
  margin: 0 -24px -20px;
  padding: 12px 24px 16px;
  background: linear-gradient(180deg, rgba(8, 12, 34, 0) 0%, rgba(8, 12, 34, 0.96) 30%);
}

@media (max-width: 760px) {
  .career-body {
    display: flex;
    flex-direction: column;
  }
  .chapter-rail {
    flex: none;
    min-height: 96px;
  }
  .chapter-detail {
    flex: none;
  }
  .panel-career .panel-title {
    font-size: 20px;
  }
  .career-summary strong {
    font-size: 15px;
  }
  .career-summary span {
    font-size: 9px;
  }
}

/* Game over (failed event / DNF) */
.results-gameover {
  margin: -4px 0 12px;
  padding: 8px 12px;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: #ffd0d8;
  border: 1px solid rgba(255, 77, 109, 0.5);
  background: rgba(255, 77, 109, 0.12);
}

.screen-results.failed .overlay-box {
  border-top-color: var(--danger);
}

.screen-results.failed .results-place {
  background: linear-gradient(180deg, #ffd0d8, #ff4d6d);
  -webkit-background-clip: text;
  background-clip: text;
}

.screen-results.active .overlay-box {
  animation: results-in 600ms var(--ease-out);
}

@keyframes results-in {
  from { transform: translateY(30px) scale(0.96); opacity: 0; }
  to { transform: none; opacity: 1; }
}
