/* ==========================================================================
   Informa AI — Command layer.
   The immersive pass on top of the Signal Atlas design system: the homepage
   command deck (telemetry, transmissions, live wire), the ambient signal network,
   scroll-driven depth, cinematic page transitions and spring-loaded controls.
   Every effect is decorative: headlines, summaries and publisher links read the
   same with motion off, in forced colours, in print and without JavaScript.
   ========================================================================== */

:root {
  --deck-cyan: #22d3ee; --deck-ice: #e0f7ff; --deck-navy: #061632; --deck-glass: #06163299;
  --deck-curve: cubic-bezier(.16, 1, .3, 1);
}

/* ---------- Ambient signal network (ambient.js) ---------- */
.ambient-field { position: fixed; inset: 0; z-index: -1; width: 100vw; height: 100vh; pointer-events: none; opacity: .9; }
:root[data-motion="off"] .ambient-field { display: none; }

/* ---------- Site-wide motion switch ---------- */
.motion-toggle {
  display: inline-grid; place-items: center; width: 38px; height: 38px; flex: none; padding: 0; cursor: pointer;
  border: 1px solid var(--line); border-radius: 999px; background: var(--control-surface, var(--paper)); color: var(--green);
  box-shadow: var(--sys-e1); transition: border-color 160ms, color 160ms, background-color 160ms;
}
.motion-toggle:hover { border-color: var(--sys-signal); color: var(--sys-signal); }
.motion-toggle:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.motion-toggle .motion-pause { display: none; }
.motion-toggle .motion-orbit { transform-origin: 10px 10px; animation: deck-spin 9s linear infinite; }
.motion-toggle[aria-pressed="true"] .motion-pause { display: inline; }
.motion-toggle[aria-pressed="true"] :is(.motion-orbit, circle) { display: none; }
@keyframes deck-spin { to { transform: rotate(360deg); } }

/* Pausing motion stops every decorative animation and transition on the site. */
:root[data-motion="off"] *, :root[data-motion="off"] *::before, :root[data-motion="off"] *::after {
  animation-duration: .001ms !important; animation-iteration-count: 1 !important;
  transition-duration: .001ms !important; scroll-behavior: auto !important;
}
:root[data-motion="off"] :is(.story, .desk-masthead, .curiosity-card, [data-sys-tilt]) { transform: none !important; }

/* ---------- Spring-loaded controls (ambient.js sets --mag-x/--mag-y) ---------- */
.button.primary, .signal-region, .deck-wire-toggle, .curiosity-chip { translate: var(--mag-x, 0) var(--mag-y, 0); }
.button.primary { position: relative; isolation: isolate; overflow: hidden; }
.button.primary::after {
  content: ""; position: absolute; inset: 0; z-index: -1; pointer-events: none; opacity: 0; transition: opacity 220ms;
  background: radial-gradient(120px circle at var(--glow-x, 50%) var(--glow-y, 50%), #ffffff55, transparent 60%);
}
.button.primary:hover::after { opacity: 1; }

/* ==========================================================================
   The command deck (homepage masthead)
   ========================================================================== */
.command-deck {
  --deck-pad: clamp(21px, 3vw, 39px);
  grid-template-columns: minmax(0, 1fr) minmax(0, .95fr); grid-template-rows: auto 1fr auto;
  align-items: start; row-gap: 18px; min-height: clamp(470px, 46vw, 610px); padding: var(--deck-pad) var(--deck-pad) 0;
}
.command-deck .deck-copy { grid-column: 1; grid-row: 1; max-width: 560px; }
.edition-entry { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-block: 12px; }
.command-deck .edition-entry .button.secondary { background: #0e2345; color: #eaf4ff; border-color: #7591b5; }
.command-deck .edition-entry .text-button { color: #bce8ff; }
.command-deck .edition-entry .edition-topic { min-height: 34px; padding: 4px 10px; font-size: .8rem; }
.command-deck .edition-entry .edition-topic[aria-pressed="true"] { background: #c3ebff; color: #101d33; }
.edition-interests { min-inline-size: 0; padding: 10px 0 0; margin: 8px 0; border: 0; border-top: 1px solid #7591b5; }
.edition-interests legend { color: #eaf4ff; padding-inline: 0 8px; font-weight: 650; }
.command-deck .edition-interests p { color: #b9cce5; margin: 0; font-size: .8rem; }
.command-deck .edition-freshness { color: #b9cce5; margin-block: 10px; font-size: .8rem; }
.command-deck::before {
  background:
    radial-gradient(1px 1px at 12% 22%, #e0f7ffcc 50%, transparent 51%), radial-gradient(1px 1px at 31% 71%, #e0f7ff99 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 47% 14%, #a5f3fcaa 50%, transparent 51%), radial-gradient(1px 1px at 58% 86%, #e0f7ff88 50%, transparent 51%),
    radial-gradient(1px 1px at 69% 9%, #ffffffaa 50%, transparent 51%), radial-gradient(1.5px 1.5px at 86% 30%, #a5f3fc99 50%, transparent 51%),
    radial-gradient(1px 1px at 94% 64%, #e0f7ffaa 50%, transparent 51%), radial-gradient(1px 1px at 22% 48%, #ffffff77 50%, transparent 51%),
    radial-gradient(260px 200px at 22% 30%, #38bdf833, transparent 70%),
    radial-gradient(320px 220px at 78% 70%, #22d3ee2e, transparent 70%);
}
.command-deck .edition-coverage {
  grid-column: 1; grid-row: 2; align-self: end; justify-self: start; width: min(100%, 430px); max-width: 430px; margin: 0;
}

/* The globe owns the right half of the deck. */
.command-deck .signal-globe {
  --globe-size: clamp(320px, 33vw, 520px);
  right: clamp(-30px, -1vw, 10px); top: calc(50% - 26px);
}
.command-deck .signal-globe::before {
  inset: 6%;
  background:
    radial-gradient(circle at 50% 50%, #0b2a5c00 55%, #22d3ee38 63%, #22d3ee14 70%, transparent 75%),
    radial-gradient(circle at 36% 30%, #2563eb80, #0b2a5c 45%, #040d22 72%);
  box-shadow: 0 0 120px 24px #0ea5e92e, 0 0 40px 2px #22d3ee33, inset -40px -50px 90px #000000a0, inset 18px 18px 50px #7dd3fc22;
}
/* An orbital ring frames the globe like an instrument bezel. */
.command-deck .signal-globe.is-live::after {
  content: ""; position: absolute; inset: -2%; border-radius: 50%; pointer-events: none;
  border: 1px dashed #7dd3fc2e; outline: 1px solid #7dd3fc14; outline-offset: 18px;
  animation: deck-spin 120s linear infinite;
}

/* ---------- Telemetry ---------- */
.deck-telemetry {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(104px, 1fr)); gap: 1px; max-width: 520px;
  margin: 20px 0 0; border: 1px solid #7dd3fc33; border-radius: 14px; overflow: hidden;
  background: #7dd3fc22; backdrop-filter: blur(10px) saturate(1.2);
  animation: sys-hero-in 900ms var(--deck-curve) 360ms backwards;
}
.deck-telemetry[hidden] { display: none; }
.deck-stat { position: relative; margin: 0; padding: 10px 12px 9px; background: color-mix(in srgb, #061632 82%, transparent); }
.deck-stat[hidden] { display: none; }
.deck-stat::after {
  content: ""; position: absolute; inset: 0; pointer-events: none; opacity: .5;
  background: repeating-linear-gradient(180deg, transparent 0 3px, #7dd3fc0a 3px 4px);
}
.deck-stat dt { margin: 0; color: #7dd3fc; font: 650 9.5px/1.3 var(--font-ui); letter-spacing: .1em; text-transform: uppercase; }
.deck-stat dd {
  margin: 4px 0 0; font: 600 clamp(19px, 1.9vw, 25px)/1 var(--font-ui); font-variant-numeric: tabular-nums; letter-spacing: -.02em;
  background: linear-gradient(180deg, #ffffff, #a5f3fc); -webkit-background-clip: text; background-clip: text; color: transparent;
}

/* ---------- Transmissions ---------- */
.deck-transmission {
  position: absolute; z-index: 5; left: 0; top: 0; translate: var(--card-x, 50%) var(--card-y, 50%);
  width: min(260px, 62vw); padding: 11px 13px 10px; pointer-events: auto;
  border: 1px solid #7dd3fc55; border-top-color: #a5f3fcaa; border-radius: 12px;
  background: linear-gradient(160deg, #0b2a5ce6, #061632f2); color: #e0f7ff;
  backdrop-filter: blur(14px) saturate(1.4);
  box-shadow: 0 24px 48px -20px #000d, 0 0 0 1px #00000040, 0 0 30px -6px #22d3ee55, inset 0 1px 0 #ffffff22;
  transition: opacity 400ms;
}
.deck-transmission[hidden] { display: none; }
.deck-transmission[data-state="in"] { animation: deck-transmit 700ms var(--deck-curve) both; }
.deck-transmission[data-state="out"] { opacity: .0; }
.deck-transmission[data-facing="false"] { opacity: .45; }
.deck-transmission-region {
  display: flex; align-items: center; gap: 7px; color: #67e8f9;
  font: 700 9.5px/1.3 var(--font-ui); letter-spacing: .12em; text-transform: uppercase;
}
.deck-transmission-region::before {
  content: ""; width: 7px; height: 7px; border-radius: 50%; background: #22d3ee; box-shadow: 0 0 0 3px #22d3ee33, 0 0 12px #22d3ee;
  animation: deck-blip 1.6s ease-out infinite;
}
.deck-transmission-link {
  display: block; margin: 6px 0 5px; color: #ffffff; text-decoration: none;
  font: 400 16.5px/1.22 var(--serif); letter-spacing: -.005em; text-wrap: balance;
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 3; overflow: hidden;
}
.deck-transmission-link:hover { text-decoration: underline; text-decoration-color: #67e8f9; text-underline-offset: 3px; }
.deck-transmission-link:focus-visible { outline: 2px solid #a5f3fc; outline-offset: 3px; border-radius: 4px; }
.deck-transmission-meta { display: block; color: #9cc3e6; font: 500 11px/1.4 var(--font-ui); }
@keyframes deck-transmit {
  0% { opacity: 0; scale: .86; filter: blur(8px); clip-path: inset(48% 0 48% 0 round 12px); }
  55% { opacity: 1; filter: blur(0); clip-path: inset(0 0 0 0 round 12px); }
  100% { opacity: 1; scale: 1; clip-path: inset(0 0 0 0 round 12px); }
}
@keyframes deck-blip { 0% { box-shadow: 0 0 0 0 #22d3ee88, 0 0 12px #22d3ee; } 100% { box-shadow: 0 0 0 9px #22d3ee00, 0 0 12px #22d3ee; } }

.deck-beam {
  position: absolute; z-index: 4; left: var(--hub-x, 50%); top: var(--hub-y, 50%); width: var(--beam-length, 30px); height: 1px;
  pointer-events: none; background: linear-gradient(90deg, #a5f3fc, #22d3ee55); transform-origin: 0 50%;
  rotate: var(--beam-angle, 0rad); box-shadow: 0 0 8px #22d3ee;
}
.deck-beam[hidden], .deck-beam[data-facing="false"] { display: none; }

/* ---------- Live wire ---------- */
.deck-wire {
  grid-column: 1 / -1; grid-row: 3; position: relative; z-index: 3; display: flex; align-items: center; gap: 12px;
  margin: 4px calc(var(--deck-pad) * -1) 0; padding: 9px var(--deck-pad);
  border-top: 1px solid #7dd3fc2e; background: linear-gradient(180deg, #04102499, #040d20d9);
  backdrop-filter: blur(10px);
}
.deck-wire[hidden] { display: none; }
.deck-wire-label {
  display: inline-flex; align-items: center; gap: 7px; flex: none; color: #a5f3fc;
  font: 700 10px/1 var(--font-ui); letter-spacing: .14em; text-transform: uppercase;
}
.deck-wire-dot { width: 7px; height: 7px; border-radius: 50%; background: #22d3ee; animation: deck-blip 1.6s ease-out infinite; }
.deck-wire-track {
  display: flex; flex: 1; min-width: 0; overflow: hidden;
  mask-image: linear-gradient(90deg, transparent, #000 4%, #000 92%, transparent);
}
.deck-wire-list {
  display: flex; flex: none; gap: 0; margin: 0; padding: 0; list-style: none;
  animation: deck-wire var(--wire-duration, 80s) linear infinite;
}
.deck-wire-list li { display: flex; flex: none; }
.deck-wire-item {
  display: inline-flex; align-items: baseline; gap: 8px; min-height: 30px; padding: 6px 22px 6px 0; align-items: center;
  color: #e0f0ff; text-decoration: none; white-space: nowrap; font: 500 12.5px/1.2 var(--font-ui);
}
.deck-wire-item::after { content: "◆"; margin-left: 14px; color: #22d3ee66; font-size: 7px; }
.deck-wire-item:hover .deck-wire-title { text-decoration: underline; text-underline-offset: 3px; text-decoration-color: #67e8f9; }
.deck-wire-item:focus-visible { outline: 2px solid #a5f3fc; outline-offset: -2px; border-radius: 6px; }
.deck-wire-region { color: #67e8f9; font-weight: 700; font-size: 10px; letter-spacing: .06em; text-transform: uppercase; }
.deck-wire-source { color: #8fb3d6; font-size: 11.5px; }
.deck-wire:is(:hover, :focus-within, [data-paused="true"]) .deck-wire-list { animation-play-state: paused; }
@keyframes deck-wire { to { translate: -100% 0; } }
.deck-wire-toggle {
  flex: none; min-height: 30px; padding: 4px 12px; cursor: pointer; border: 1px solid #7dd3fc55; border-radius: 999px;
  background: #061632; color: #e0f7ff; font: 650 11px/1 var(--font-ui);
}
.deck-wire-toggle:hover { border-color: #67e8f9; }
.deck-wire-toggle:focus-visible { outline: 2px solid #a5f3fc; outline-offset: 2px; }
/* Paused or still: the wire becomes an ordinary scrollable row, without the looping copy. */
.deck-wire[data-paused="true"] .deck-wire-track { overflow-x: auto; scrollbar-width: thin; }
.deck-wire[data-paused="true"] .deck-wire-list { animation: none; }
.deck-wire[data-paused="true"] .deck-wire-list[aria-hidden="true"] { display: none; }

@media (max-width: 1100px) {
  .command-deck { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto auto auto; min-height: 0; }
  .command-deck .signal-globe { --globe-size: 330px; right: -80px; top: -10px; translate: none; opacity: .8; }
  .command-deck .edition-coverage { grid-row: 2; justify-self: stretch; width: auto; max-width: none; }
  .deck-transmission, .deck-beam { display: none !important; }
}
@media (max-width: 760px) {
  .command-deck .signal-globe { --globe-size: 230px; right: -84px; top: -36px; opacity: .55; }
  .deck-telemetry { grid-template-columns: repeat(2, minmax(0, 1fr)); max-width: none; }
  .deck-telemetry[data-count="1"] .deck-stat, .deck-telemetry[data-count="3"] .deck-stat[data-last] { grid-column: 1 / -1; }
  .deck-wire { gap: 8px; }
  .deck-wire-label { font-size: 0; gap: 0; }
  .deck-wire-item { font-size: 12px; }
}

/* ==========================================================================
   Scroll-driven depth: cards rise out of the page as they enter the viewport.
   Uses individual transform properties so hover tilts keep working.
   ========================================================================== */
@supports (animation-timeline: view()) {
  @media (prefers-reduced-motion: no-preference) {
    :root:not([data-motion="off"]) .stories:not(.story-list) > .story {
      animation: deck-surface linear both; animation-timeline: view(); animation-range: entry 0% entry 70%;
    }
    :root:not([data-motion="off"]) :is(.priority-signals, .curiosity-card, .research-panel, .information-card, .source-row) {
      animation: deck-surface linear both; animation-timeline: view(); animation-range: entry 0% entry 55%;
    }
    /* The globe recedes into the deck as the reader scrolls past it. */
    :root:not([data-motion="off"]) .command-deck .signal-globe {
      animation: deck-recede linear both; animation-timeline: view(); animation-range: exit 0% exit 100%;
    }
  }
}
@keyframes deck-surface {
  from { opacity: 0; translate: 0 46px; rotate: x 16deg; scale: .96; }
  to { opacity: 1; translate: 0 0; rotate: x 0deg; scale: 1; }
}
@keyframes deck-recede { to { scale: .72; opacity: .2; filter: blur(3px); } }
.stories:not(.story-list) { perspective: 1400px; }

/* ==========================================================================
   Cinematic page transitions between the Reading Room, Research Desk and
   other pages (cross-document View Transitions; ignored where unsupported).
   ========================================================================== */
.site-header { view-transition-name: site-header; }
@media (prefers-reduced-motion: no-preference) {
  ::view-transition-old(root) { animation: 280ms cubic-bezier(.4, 0, 1, 1) both deck-page-out; }
  ::view-transition-new(root) { animation: 520ms var(--deck-curve) both deck-page-in; }
}
:root[data-motion="off"]::view-transition-old(root), :root[data-motion="off"]::view-transition-new(root) { animation: none; }
@keyframes deck-page-out { to { opacity: 0; transform: scale(.985) translateY(-6px); filter: blur(6px); } }
@keyframes deck-page-in { from { opacity: 0; transform: scale(1.012) translateY(14px); filter: blur(8px); } }

/* ==========================================================================
   Page heroes across the product share the holographic deck treatment.
   ========================================================================== */
:is(.research-header, .curiosity-hero, .information-hero, .directory-intro, .preview-empty) { position: relative; isolation: isolate; }
.holo-floor {
  position: absolute; inset: 0; z-index: -1; overflow: hidden; pointer-events: none; border-radius: inherit;
}
.holo-floor::before {
  content: ""; position: absolute; inset: 55% -20% -60%;
  background:
    repeating-linear-gradient(90deg, color-mix(in srgb, var(--sys-signal) 22%, transparent) 0 1px, transparent 1px 56px),
    repeating-linear-gradient(0deg, color-mix(in srgb, var(--sys-signal) 18%, transparent) 0 1px, transparent 1px 56px);
  transform: perspective(480px) rotateX(66deg); transform-origin: 50% 0;
  mask-image: linear-gradient(180deg, #000 0%, transparent 80%);
  animation: deck-floor 14s linear infinite;
}
.holo-floor::after {
  content: ""; position: absolute; inset: -40% -10%; opacity: .55;
  background: linear-gradient(105deg, transparent 40%, color-mix(in srgb, var(--sys-signal) 16%, transparent) 50%, transparent 60%);
  animation: deck-sweep 9s var(--deck-curve) infinite;
}
@keyframes deck-floor { to { background-position: 0 0, 0 56px; } }
@keyframes deck-sweep { 0%, 35% { translate: -60% 0; } 100% { translate: 60% 0; } }

/* ---------- Brief Builder: an assembly bay ---------- */
.preview-empty { overflow: hidden; }
.preview-empty .holo-floor::before { inset: 78% -20% -70%; }
.preview-empty .preview-document { animation: deck-float 6s ease-in-out infinite; }
@keyframes deck-float { 50% { translate: 0 -6px; rotate: y 10deg; } }
/* While a brief is generating, a scan line sweeps the preview bay. */
.preview-empty::after {
  content: ""; position: absolute; inset: 0 0 auto; height: 38%; z-index: 0; pointer-events: none; opacity: 0;
  background: linear-gradient(180deg, transparent, color-mix(in srgb, var(--sys-signal) 22%, transparent) 85%, var(--sys-signal) 100%);
  translate: 0 -100%;
}
#composer:has(#generate:disabled) .preview-empty::after { opacity: 1; animation: deck-scan 1.6s cubic-bezier(.5, 0, .5, 1) infinite; }
#composer:has(#generate:disabled) .preview-empty .preview-document { animation-duration: 1.2s; }
@keyframes deck-scan { to { translate: 0 270%; } }
.workspace-content .composer.open { animation: deck-bay-in 520ms var(--deck-curve) both; }
@keyframes deck-bay-in { from { opacity: 0; scale: .97; translate: 0 18px; filter: blur(6px); } }

/* ---------- Accessibility and output fallbacks ---------- */
@media (prefers-reduced-motion: reduce) {
  .deck-wire-list { animation: none; }
  .deck-wire-list[aria-hidden="true"] { display: none; }
  .deck-wire-track { overflow-x: auto; }
  .deck-transmission[data-state="in"], .motion-toggle .motion-orbit, .holo-floor::before, .holo-floor::after,
  .command-deck .signal-globe.is-live::after, .deck-wire-dot, .deck-transmission-region::before,
  .preview-empty .preview-document, .preview-empty::after, .workspace-content .composer.open { animation: none; }
}
@media (forced-colors: active) {
  .ambient-field, .holo-floor, .deck-beam { display: none !important; }
  .deck-telemetry, .deck-stat, .deck-transmission, .deck-wire, .deck-wire-toggle { forced-color-adjust: auto; background: Canvas; color: CanvasText; border-color: CanvasText; }
  .deck-stat dd { background: none; color: CanvasText; }
}
@media print {
  .ambient-field, .motion-toggle, .holo-floor, .deck-wire, .deck-transmission, .deck-beam { display: none !important; }
  .story, .priority-signals, .curiosity-card { animation: none !important; opacity: 1 !important; translate: none !important; rotate: none !important; scale: none !important; }
}

/* On small screens the motion switch floats bottom-left instead of crowding the header. */
@media (max-width: 560px) {
  .motion-toggle.is-floating { position: fixed; left: 14px; bottom: calc(14px + env(safe-area-inset-bottom)); z-index: 45; width: 40px; height: 40px; box-shadow: var(--sys-e2); }
}

/* ---------- Signal Orb: the globe docks beside the feed and follows the story being read ---------- */
.signal-orb {
  position: fixed; right: 76px; bottom: max(18px, env(safe-area-inset-bottom)); z-index: 40; display: flex; align-items: center; gap: 12px;
  max-width: 320px; padding: 8px 16px 8px 8px; border: 1px solid rgb(103 232 249 / 28%); border-radius: 999px;
  color: #e7f1fc; text-align: left; cursor: pointer;
  background: linear-gradient(150deg, rgb(6 22 50 / 92%), rgb(11 42 92 / 88%));
  box-shadow: 0 18px 40px -18px rgb(4 11 25 / 70%), inset 0 1px 0 rgb(255 255 255 / 10%);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  animation: orb-dock 520ms var(--sys-curve, ease) both;
}
.signal-orb[hidden] { display: none; }
.signal-orb:hover { border-color: rgb(103 232 249 / 55%); }
.signal-orb:focus-visible { outline: 2px solid #67e8f9; outline-offset: 3px; }
.signal-orb-sphere {
  position: relative; flex: none; width: 64px; height: 64px; border-radius: 50%; overflow: hidden;
  background: radial-gradient(circle at 35% 30%, rgb(56 189 248 / 30%), rgb(4 11 25 / 90%) 70%);
  box-shadow: 0 0 0 1px rgb(103 232 249 / 25%), 0 0 26px -4px rgb(34 211 238 / 55%);
}
.signal-orb-sphere canvas { display: block; width: 64px; height: 64px; }
.signal-orb-text { display: grid; gap: 2px; min-width: 0; }
.signal-orb-kicker { color: #67e8f9; font: 700 9px/1.4 var(--font-ui); letter-spacing: .14em; text-transform: uppercase; }
.signal-orb-place { overflow: hidden; color: #ffffff; font: 600 13px/1.35 var(--font-ui); text-overflow: ellipsis; white-space: nowrap; }
@keyframes orb-dock { from { opacity: 0; transform: translate3d(0, 18px, 0) scale(.9); } to { opacity: 1; transform: none; } }
:root[data-motion="off"] .signal-orb { display: none; }
@media print { .signal-orb { display: none; } }
