/* LUMIVALE — Codex Rail (help-center)
   Scroll-spy chapter rail · ticket stream · floating command search · marquee ticker
   Independent of Signal Chamber / bento / nocturne help patterns */

@import url('https://fonts.googleapis.com/css2?family=Newsreader:opsz,ital,wght@6..72,500;6..72,600;6..72,700&family=Space+Grotesk:wght@400;500;600;700&display=swap');

.page-codex {
  --cx-bg: #12100e;
  --cx-panel: #1c1916;
  --cx-line: rgba(245, 240, 232, 0.1);
  --cx-text: #f5f0e8;
  --cx-mute: #d0cbbf;
  --cx-cobalt: #4c9fff;
  --cx-saffron: #e8a838;
  --cx-ember: #ff6a3d;
  --cx-font: 'Space Grotesk', system-ui, sans-serif;
  --cx-display: 'Newsreader', Georgia, serif;
  --cx-ease: cubic-bezier(0.22, 1, 0.36, 1);
  --cx-cmd-h: 7.5rem;
  background: var(--cx-bg) !important;
  color: var(--cx-text);
  font-family: var(--cx-font);
}

.page-codex .page-main {
  overflow-x: clip;
  padding-bottom: calc(var(--cx-cmd-h) + 2rem);
}

.cx {
  position: relative;
  padding: 1.5rem var(--space-container, 1.25rem) 2rem;
  max-width: 1180px;
  margin: 0 auto;
}

.cx-mast {
  margin-bottom: 1.5rem;
  max-width: 40rem;
}

.cx-brand {
  margin: 0 0 0.4rem;
  font-size: 0.72rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--cx-cobalt);
  font-weight: 700;
}

.cx-mast h1 {
  margin: 0 0 0.55rem;
  font-family: var(--cx-display);
  font-weight: 600;
  font-size: clamp(2.6rem, 8vw, 4.4rem);
  letter-spacing: -0.03em;
  line-height: 0.96;
}

.cx-mast h1 em {
  font-style: italic;
  color: var(--cx-saffron);
  font-weight: 500;
}

.cx-lede {
  margin: 0 0 0.75rem;
  color: var(--cx-mute);
  font-size: 1.05rem;
  line-height: 1.55;
}

.cx-stat {
  margin: 0;
  font-size: 0.85rem;
  color: var(--cx-mute);
}

.cx-stat strong {
  color: var(--cx-ember);
  font-weight: 700;
}

/* Marquee ticker */
.cx-ticker {
  margin: 0 calc(-1 * var(--space-container, 1.25rem)) 1.75rem;
  overflow: hidden;
  border-block: 1px solid var(--cx-line);
  background: rgba(28, 25, 22, 0.65);
  mask-image: linear-gradient(90deg, transparent, #000 8%, #000 92%, transparent);
}

.cx-ticker-track {
  display: flex;
  gap: 0.35rem;
  width: max-content;
  padding: 0.75rem 0;
  animation: cxMarquee 38s linear infinite;
}

.cx-ticker:hover .cx-ticker-track {
  animation-play-state: paused;
}

@keyframes cxMarquee {
  from { transform: translateX(0); }
  to { transform: translateX(-50%); }
}

.cx-ticker-item {
  flex: 0 0 auto;
  padding: 0.45rem 1rem;
  border-radius: 999px;
  text-decoration: none;
  color: var(--cx-text);
  font-weight: 600;
  font-size: 0.84rem;
  border: 1px solid var(--cx-line);
  background: rgba(0, 0, 0, 0.25);
  transition: border-color 0.25s, color 0.25s, background 0.25s, transform 0.25s;
}

.cx-ticker-item:hover {
  border-color: rgba(76, 159, 255, 0.5);
  color: var(--cx-cobalt);
  background: rgba(76, 159, 255, 0.08);
  transform: translateY(-2px);
}

/* Layout: rail + stream */
.cx-layout {
  display: grid;
  grid-template-columns: 11rem minmax(0, 1fr);
  gap: 1.5rem;
  align-items: start;
}

.cx-rail {
  position: sticky;
  top: calc(var(--dock-h, 4rem) + 0.75rem);
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  padding: 0.5rem;
  border-radius: 20px;
  background: rgba(28, 25, 22, 0.75);
  border: 1px solid var(--cx-line);
  backdrop-filter: blur(14px);
}

.cx-rail-progress {
  position: absolute;
  width: 0;
  height: 0;
}

.cx-rail-item {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.55rem;
  align-items: center;
  padding: 0.7rem 0.75rem;
  border-radius: 14px;
  text-decoration: none;
  color: var(--cx-mute);
  border: 1px solid transparent;
  transition: background 0.3s, color 0.3s, border-color 0.3s, transform 0.3s var(--cx-ease);
}

.cx-rail-item:hover {
  color: var(--cx-text);
  background: rgba(255, 255, 255, 0.04);
  transform: translateX(3px);
}

.cx-rail-item.is-active {
  color: #0c1018;
  background: var(--cx-saffron);
  border-color: transparent;
  box-shadow: 0 10px 28px rgba(232, 168, 56, 0.28);
}

.cx-rail-code {
  font-family: var(--cx-display);
  font-weight: 700;
  font-size: 0.95rem;
}

.cx-rail-label {
  font-weight: 700;
  font-size: 0.88rem;
}

/* Stream + scroll snap */
.cx-stream {
  display: flex;
  flex-direction: column;
  gap: 2.5rem;
  scroll-margin-top: 6rem;
}

.cx-chapter {
  scroll-margin-top: calc(var(--dock-h, 4rem) + 1rem);
  scroll-snap-align: start;
}

.cx-chapter-head {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 1rem;
  align-items: start;
  margin-bottom: 1rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--cx-line);
}

.cx-chapter-code {
  font-family: var(--cx-display);
  font-size: clamp(2.8rem, 6vw, 4rem);
  font-weight: 600;
  line-height: 0.9;
  color: var(--cx-cobalt);
  letter-spacing: -0.04em;
  text-shadow: 0 0 40px rgba(76, 159, 255, 0.25);
}

.cx-chapter-kicker {
  margin: 0 0 0.2rem;
  font-size: 0.68rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--cx-ember);
  font-weight: 700;
}

.cx-chapter-head h2 {
  margin: 0 0 0.3rem;
  font-family: var(--cx-display);
  font-size: clamp(1.6rem, 3vw, 2.1rem);
  font-weight: 600;
  letter-spacing: -0.02em;
}

.cx-chapter-head p {
  margin: 0;
  color: var(--cx-mute);
}

/* Ticket FAQs */
.cx-tickets {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.cx-ticket {
  border-radius: 18px;
  background: var(--cx-panel);
  border: 1px solid var(--cx-line);
  overflow: hidden;
  transition: border-color 0.3s, box-shadow 0.35s, transform 0.35s var(--cx-ease);
  opacity: 0;
  transform: translateY(14px);
  animation: cxTicketIn 0.5s var(--cx-ease) forwards;
  animation-delay: calc(var(--t, 0) * 50ms);
}

@keyframes cxTicketIn {
  to { opacity: 1; transform: none; }
}

.cx-ticket:hover {
  border-color: rgba(76, 159, 255, 0.3);
}

.cx-ticket.is-open {
  border-color: rgba(232, 168, 56, 0.45);
  box-shadow: 0 18px 44px rgba(0, 0, 0, 0.35);
}

.cx-ticket.is-match {
  border-color: rgba(76, 159, 255, 0.55);
  box-shadow: 0 0 0 1px rgba(76, 159, 255, 0.25);
}

.cx-ticket-q {
  width: 100%;
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 0.85rem;
  align-items: center;
  padding: 1rem 1.05rem;
  border: 0;
  background: transparent;
  color: inherit;
  text-align: left;
  cursor: pointer;
  font-family: inherit;
}

.cx-ticket-num {
  font-family: var(--cx-display);
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--cx-saffron);
}

.cx-ticket-text {
  font-weight: 650;
  font-size: 0.98rem;
  line-height: 1.35;
}

.cx-ticket-mark {
  width: 1.5rem;
  height: 1.5rem;
  border-radius: 50%;
  border: 1px solid var(--cx-line);
  position: relative;
  transition: transform 0.35s var(--cx-ease), background 0.3s, border-color 0.3s;
}

.cx-ticket-mark::before,
.cx-ticket-mark::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  background: var(--cx-mute);
  transition: transform 0.35s var(--cx-ease), background 0.3s;
}

.cx-ticket-mark::before {
  width: 10px;
  height: 1.5px;
  transform: translate(-50%, -50%);
}

.cx-ticket-mark::after {
  width: 1.5px;
  height: 10px;
  transform: translate(-50%, -50%);
}

.cx-ticket.is-open .cx-ticket-mark {
  background: var(--cx-saffron);
  border-color: var(--cx-saffron);
  transform: rotate(90deg);
}

.cx-ticket.is-open .cx-ticket-mark::before,
.cx-ticket.is-open .cx-ticket-mark::after {
  background: #1a1208;
}

.cx-ticket.is-open .cx-ticket-mark::after {
  transform: translate(-50%, -50%) scaleY(0);
}

.cx-ticket-a {
  padding: 0 1.05rem 1.1rem 3.4rem;
  color: var(--cx-mute);
  line-height: 1.6;
  font-size: 0.95rem;
  animation: cxAnswer 0.35s var(--cx-ease);
}

@keyframes cxAnswer {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: none; }
}

.cx-ticket-a p {
  margin: 0;
}

.cx-ticket-a a {
  color: var(--cx-cobalt);
  font-weight: 650;
  text-underline-offset: 0.15em;
}

.cx-ticket-a a:hover {
  color: #7ab8ff;
}

/* Floating command */
.cx-cmd {
  position: fixed;
  z-index: 70;
  left: 50%;
  bottom: 1.1rem;
  transform: translateX(-50%);
  width: min(640px, calc(100vw - 1.5rem));
  padding: 0.55rem;
  border-radius: 22px;
  background: rgba(18, 16, 14, 0.88);
  border: 1px solid rgba(245, 240, 232, 0.14);
  box-shadow:
    0 24px 60px rgba(0, 0, 0, 0.55),
    0 0 0 1px rgba(76, 159, 255, 0.08);
  backdrop-filter: blur(20px) saturate(140%);
}

.cx-cmd.is-open {
  border-color: rgba(76, 159, 255, 0.35);
}

.cx-cmd-bar {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.35rem 0.55rem 0.35rem 0.75rem;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--cx-line);
}

.cx-cmd-glyph {
  color: var(--cx-cobalt);
  font-size: 1.05rem;
}

.cx-cmd-bar input {
  flex: 1;
  border: 0;
  background: transparent;
  color: var(--cx-text);
  font-family: inherit;
  font-size: 0.95rem;
  outline: none;
  min-width: 0;
  padding: 0.55rem 0;
}

.cx-cmd-bar input::placeholder {
  color: var(--cx-mute);
}

.cx-cmd-kbd {
  font-size: 0.7rem;
  font-weight: 700;
  padding: 0.2rem 0.45rem;
  border-radius: 6px;
  border: 1px solid var(--cx-line);
  color: var(--cx-mute);
}

.cx-cmd-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  padding: 0.55rem 0.35rem 0.15rem;
}

.cx-cmd-tag {
  border: 1px solid var(--cx-line);
  background: transparent;
  color: var(--cx-mute);
  border-radius: 999px;
  padding: 0.3rem 0.65rem;
  font-size: 0.75rem;
  font-weight: 650;
  font-family: inherit;
  cursor: pointer;
  transition: color 0.25s, border-color 0.25s, background 0.25s;
}

.cx-cmd-tag:hover,
.cx-cmd-tag.is-on {
  color: var(--cx-text);
  border-color: rgba(232, 168, 56, 0.45);
  background: rgba(232, 168, 56, 0.1);
}

.cx-cmd-hits {
  margin-top: 0.45rem;
  max-height: min(40vh, 280px);
  overflow-y: auto;
  border-radius: 14px;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--cx-line);
}

.cx-cmd-hits ul {
  list-style: none;
  margin: 0;
  padding: 0.35rem;
}

.cx-cmd-hits li button {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  align-items: flex-start;
  text-align: left;
  border: 0;
  background: transparent;
  color: inherit;
  padding: 0.7rem 0.75rem;
  border-radius: 10px;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.2s;
}

.cx-cmd-hits li button:hover:not(:disabled) {
  background: rgba(76, 159, 255, 0.12);
}

.cx-cmd-hits li button:disabled {
  cursor: default;
  opacity: 0.7;
}

.cx-cmd-hits strong {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--cx-text);
}

.cx-cmd-hits span {
  font-size: 0.75rem;
  color: var(--cx-mute);
  line-height: 1.35;
}

.page-codex .a59-tabbar {
  display: none;
}

@media (prefers-reduced-motion: reduce) {
  .cx-ticker-track,
  .cx-ticket,
  .cx-ticket-a {
    animation: none !important;
  }

  .cx-ticket {
    opacity: 1;
    transform: none;
  }

  .cx-ticker-track {
    transform: none;
    flex-wrap: wrap;
    width: auto;
    justify-content: center;
  }
}

@media (max-width: 860px) {
  .cx-layout {
    grid-template-columns: 1fr;
  }

  .cx-rail {
    position: relative;
    top: auto;
    flex-direction: row;
    overflow-x: auto;
    gap: 0.35rem;
    scrollbar-width: none;
  }

  .cx-rail::-webkit-scrollbar { display: none; }

  .cx-rail-item {
    flex: 0 0 auto;
  }

  .cx-ticket-a {
    padding-left: 1.05rem;
  }
}

@media (max-width: 520px) {
  .cx-cmd-tags {
    display: none;
  }

  .cx-ticket-q {
    grid-template-columns: 1fr auto;
  }

  .cx-ticket-num {
    display: none;
  }

  .page-codex {
    --cx-cmd-h: 5.5rem;
  }
}
