/*
  DNE Civilization Runtime — design.md tokens and section styles.
  Loaded after globals.css; overrides cinematic shell where specified.
*/

:root {
  --dne-bg: #000000;
  --dne-surface: #0B1118;
  --dne-surface-raised: #101A24;
  --dne-surface-light: #182838;
  --dne-signal: #FFAB00;
  --dne-heat: #FF6D00;
  --dne-pressure: #E65100;
  --dne-success: #66E6A3;
  --dne-danger: #FF3B30;
  --dne-text: #FFFFFF;
  --dne-text-muted: #D4A373;
}

::selection {
  background: rgba(255, 109, 0, 0.3);
}

.civ-civilization-runtime {
  --civ-cinematic-bg: var(--dne-bg);
  --civ-cinematic-glow: rgba(255, 171, 0, 0.1);
  --civ-cinematic-amber: rgba(255, 171, 0, 0.45);
  --civ-cinematic-cyan: rgba(255, 109, 0, 0.08);
  background: transparent;
  color: var(--dne-text);
  position: relative;
  z-index: 10;
}

.civ-mono {
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 0.92em;
  letter-spacing: 0.02em;
}

/* Atmosphere stack */
.civ-atmosphere {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}

.civ-atmosphere__void {
  position: absolute;
  inset: 0;
  background: var(--dne-bg);
}

.civ-atmosphere__beams {
  position: absolute;
  inset: -20% -10%;
  background:
    linear-gradient(115deg, transparent 40%, rgba(255, 171, 0, 0.04) 50%, transparent 60%),
    linear-gradient(245deg, transparent 35%, rgba(255, 109, 0, 0.03) 48%, transparent 58%);
  animation: civ-beam-drift 18s ease-in-out infinite alternate;
}

.civ-atmosphere__noise {
  position: absolute;
  inset: 0;
  opacity: 0.04;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

.civ-atmosphere__scanline {
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 2px,
    rgba(255, 171, 0, 0.015) 2px,
    rgba(255, 171, 0, 0.015) 3px
  );
}

.civ-atmosphere__vignette {
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at center, transparent 40%, rgba(0, 0, 0, 0.75) 100%);
}

.civ-atmosphere__noodles {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  color: rgba(255, 171, 0, 0.12);
  opacity: 0.6;
}

.civ-atmosphere__noodle {
  stroke-dasharray: 8 12;
  animation: civ-noodle-flow 24s linear infinite;
}

.civ-atmosphere__noodle--b {
  animation-duration: 32s;
  animation-direction: reverse;
}

.civ-atmosphere__pressure {
  position: absolute;
  width: 40vmin;
  height: 40vmin;
  border-radius: 50%;
  filter: blur(60px);
}

.civ-atmosphere__pressure--tl {
  top: -10%;
  left: -5%;
  background: rgba(255, 109, 0, 0.06);
}

.civ-atmosphere__pressure--br {
  bottom: -15%;
  right: -8%;
  background: rgba(255, 171, 0, 0.05);
}

@keyframes civ-beam-drift {
  from { transform: translateX(-2%) skewY(-1deg); }
  to { transform: translateX(2%) skewY(1deg); }
}

@keyframes civ-noodle-flow {
  to { stroke-dashoffset: -120; }
}

/* Badges */
.civ-badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  border: 1px solid rgba(255, 171, 0, 0.35);
  color: var(--dne-signal);
  background: rgba(11, 17, 24, 0.8);
}

.civ-badge--season {
  border-color: rgba(255, 171, 0, 0.5);
  color: var(--dne-signal);
}

.civ-badge--phase {
  border-color: rgba(255, 109, 0, 0.45);
  color: var(--dne-heat);
}

.civ-badge--state {
  font-size: 9px;
  padding: 3px 8px;
}

/* Glow cards */
.civ-cinematic-glow-card {
  --mouse-x: 50%;
  --mouse-y: 50%;
  position: relative;
  border: 1px solid rgba(255, 171, 0, 0.18);
  background:
    radial-gradient(
      420px circle at var(--mouse-x) var(--mouse-y),
      rgba(255, 171, 0, 0.08),
      transparent 45%
    ),
    linear-gradient(180deg, var(--dne-surface-raised), var(--dne-surface));
  border-radius: 14px;
  transition: border-color 0.25s ease, transform 0.25s ease;
}

.civ-cinematic-glow-card:hover {
  border-color: rgba(255, 171, 0, 0.35);
  transform: translateY(-2px);
}

/* Hero boot */
.civ-cinematic-hero__badges {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.civ-cinematic-hero__title {
  font-size: clamp(1.75rem, 6vw, 2.75rem);
  line-height: 1.08;
  margin: 0 0 16px;
  text-transform: capitalize;
  font-weight: 800;
}

.civ-cinematic-hero__doctrine {
  font-size: 14px;
  line-height: 1.55;
  color: var(--dne-text-muted);
  margin: 0 0 18px;
  max-width: 36rem;
}

.civ-cinematic-hero__countdown-timer {
  display: block;
  margin-top: 6px;
  color: var(--dne-signal);
  font-size: 13px;
}

/* Pressure bento */
.civ-pressure-bento__badges {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.civ-pressure-bento__grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

@media (min-width: 640px) {
  .civ-pressure-bento__grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

.civ-pressure-card {
  padding: 14px;
  min-height: 120px;
}

.civ-pressure-card.is-locked {
  opacity: 0.72;
}

.civ-pressure-card__head {
  margin-bottom: 10px;
}

.civ-pressure-card__label {
  margin: 0 0 6px;
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.55);
}

.civ-pressure-card__value {
  display: block;
  font-size: 1.35rem;
  margin-bottom: 8px;
  color: var(--dne-signal);
}

.civ-pressure-card__detail {
  margin: 0;
  font-size: 12px;
  line-height: 1.45;
  color: var(--dne-text-muted);
}

.civ-doctrine-strip {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 20px;
  padding: 14px 16px;
  border-left: 2px solid var(--dne-heat);
  background: rgba(11, 17, 24, 0.6);
  font-size: 13px;
  line-height: 1.5;
}

.civ-doctrine-strip__muted {
  color: var(--dne-text-muted);
  font-size: 12px;
}

/* Keycard */
.civ-keycard {
  padding: 20px;
  border-radius: 18px;
  overflow: hidden;
}

.civ-keycard__stripe {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: linear-gradient(90deg, var(--dne-signal), var(--dne-heat));
}

.civ-keycard__head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 18px;
}

.civ-keycard__brand {
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.civ-keycard__states,
.civ-keycard__access {
  display: grid;
  gap: 10px;
  margin-bottom: 16px;
}

.civ-keycard__state-row,
.civ-keycard__access-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 13px;
  padding-bottom: 8px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.civ-keycard__state-label {
  color: rgba(255, 255, 255, 0.55);
}

.civ-keycard__copy {
  margin: 0;
  font-size: 13px;
  line-height: 1.5;
  color: var(--dne-text-muted);
}

.civ-keycard__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

/* Signal log */
.civ-signal-log {
  margin-top: 24px;
  border: 1px solid rgba(255, 171, 0, 0.15);
  border-radius: 14px;
  overflow: hidden;
  background: var(--dne-surface);
}

.civ-signal-log__tabs {
  display: flex;
  gap: 6px;
  padding: 10px;
  overflow-x: auto;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  -webkit-overflow-scrolling: touch;
}

.civ-signal-log__tab {
  flex: 0 0 auto;
  min-height: 40px;
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(0, 0, 0, 0.35);
  color: rgba(255, 255, 255, 0.6);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
}

.civ-signal-log__tab.is-active {
  border-color: var(--dne-signal);
  color: var(--dne-text);
  box-shadow: 0 0 16px rgba(255, 171, 0, 0.12);
}

.civ-signal-log__tab:focus-visible {
  outline: 2px solid var(--dne-heat);
  outline-offset: 2px;
}

.civ-signal-log__terminal {
  padding: 14px 16px;
  max-height: 220px;
  overflow-y: auto;
}

.civ-signal-log__line {
  margin: 0 0 8px;
  font-size: 12px;
  line-height: 1.5;
  color: rgba(255, 255, 255, 0.78);
}

.civ-signal-log__line[hidden] {
  display: none;
}

/* Cinema memory CTA footer */
.civ-doctrine-footer {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid rgba(255, 171, 0, 0.12);
}

.civ-doctrine-footer p {
  margin: 0 0 8px;
  font-size: 12px;
  color: var(--dne-text-muted);
  line-height: 1.45;
}

/* CTA signal treatment */
.civ-civilization-runtime .runtime-blueprint-cta,
.civ-civilization-runtime .civ-cinematic-cta {
  border-color: rgba(255, 171, 0, 0.45);
  background:
    linear-gradient(180deg, rgba(255, 109, 0, 0.2), rgba(230, 81, 0, 0.12)),
    var(--dne-surface-raised);
  color: var(--dne-text);
}

.civ-civilization-runtime .runtime-blueprint-cta:hover,
.civ-civilization-runtime .civ-cinematic-cta:hover {
  box-shadow: 0 0 24px rgba(255, 171, 0, 0.18);
  border-color: var(--dne-signal);
}

.civ-civilization-runtime .runtime-blueprint-cta--secondary {
  background: rgba(11, 17, 24, 0.85);
  border-color: rgba(255, 255, 255, 0.14);
}

/* Scrollbar */
.civ-civilization-runtime,
.civ-signal-log__terminal {
  scrollbar-width: thin;
  scrollbar-color: var(--dne-signal) transparent;
}

.civ-civilization-runtime::-webkit-scrollbar,
.civ-signal-log__terminal::-webkit-scrollbar {
  width: 4px;
  height: 4px;
}

.civ-civilization-runtime::-webkit-scrollbar-thumb,
.civ-signal-log__terminal::-webkit-scrollbar-thumb {
  background: var(--dne-signal);
  border-radius: 4px;
}

/* M4J — preview shell: hide all legacy global chrome */
body[data-runtime-home-preview-shell="true"] #runtime-traversal-rail,
body[data-runtime-home-preview-shell="true"] #global-bottom-dock,
body[data-runtime-home-preview-shell="true"] .world-state-bar,
body[data-runtime-home-preview-shell="true"] .legacy-runtime-chrome,
body[data-runtime-home-preview-shell="true"] .sync-controls,
body[data-runtime-home-preview-shell="true"] .sync-logout-button {
  display: none !important;
  pointer-events: none !important;
  visibility: hidden !important;
}

/* M4J — preview shell: compass inside realm pages; external rail hidden */

.realm-screen {
  scroll-padding-top: calc(
    76px +
    env(safe-area-inset-top, 0px)
  );
}

.realm-screen > .civ-realm-compass {
  position: sticky;
  top: 0;
  z-index: 40;
}

/* Legacy rollback — external rail only when preview shell is off */
body[data-runtime-home-preview-shell="false"]:not([data-active-page="live"]) #runtime-traversal-rail {
  position: fixed !important;
  top: 0 !important;
  right: auto !important;
  left: 0 !important;
  bottom: auto !important;
  transform: none !important;
  width: 100% !important;
  max-width: 100% !important;
  display: block !important;
  z-index: 40 !important;
}

body[data-runtime-home-preview-shell="false"]:not([data-active-page="live"]) #global-bottom-dock {
  display: none !important;
}

.civ-realm-compass-shell {
  width: 100%;
}

.civ-realm-compass-shell .civ-realm-compass {
  margin: 0;
}

.civ-realm-bottom-dock {
  display: none;
}

/* Hide legacy chrome on live civilization runtime */
body[data-active-page="live"] .world-state-bar,
body[data-active-page="live"] #runtime-traversal-rail,
body[data-active-page="live"] #global-bottom-dock {
  display: none !important;
}

/* Legacy rollback — show world-state bar when preview shell off */
body[data-runtime-home-preview-shell="false"] .world-state-bar {
  display: flex;
}

/* Signal Streak strip (M3C-C) */
.civ-signal-streak {
  margin:
    0
    var(--civ-lens-inset-x, 16px)
    12px;
  scroll-margin-top: calc(var(--civ-compass-height) + env(safe-area-inset-top, 0px) + 8px);
}

.civ-signal-streak__inner {
  padding: 14px 16px;
  border-radius: 14px;
}

.civ-signal-streak__kicker {
  margin: 0 0 6px;
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--dne-text-muted);
}

.civ-signal-streak__meta {
  margin: 0 0 8px;
  font-size: 11px;
  color: var(--dne-signal);
  line-height: 1.4;
}

.civ-signal-streak__headline {
  margin: 0 0 8px;
  font-size: 1.05rem;
  line-height: 1.25;
  font-weight: 700;
  color: var(--dne-text);
}

.civ-signal-streak__detail {
  margin: 0 0 14px;
  font-size: 13px;
  line-height: 1.5;
  color: rgba(255, 255, 255, 0.72);
  max-width: 40rem;
}

.civ-signal-streak__cta {
  width: 100%;
  max-width: 280px;
  min-height: 44px;
}

.civ-signal-streak[data-signal-streak-mode="pending"] .civ-signal-streak__meta,
.civ-signal-streak[data-signal-streak-mode="disconnected"] .civ-signal-streak__meta {
  color: var(--dne-text-muted);
}

.civ-signal-streak[data-signal-streak-state="burning"] .civ-signal-streak__headline,
.civ-signal-streak[data-signal-streak-state="radiant"] .civ-signal-streak__headline,
.civ-signal-streak[data-signal-streak-state="mythic"] .civ-signal-streak__headline {
  color: var(--dne-signal);
}

@media (min-width: 640px) {
  .civ-signal-streak__cta {
    width: auto;
  }
}

@media (prefers-reduced-motion: reduce) {
  .civ-atmosphere__beams,
  .civ-atmosphere__noodle {
    animation: none;
  }
}