/*
 * Cyber desk. Decision scenarios play here, apart from the speaking player.
 * The learn-play Stimulus controller still drives the clip, the moves, and
 * the turn. These classes are the cyber surface only.
 */

.cx-shell {
  --cx-bg: #07110c;
  --cx-surface: #101a15;
  --cx-surface-2: #17241d;
  --cx-line: rgba(157, 255, 178, 0.16);
  --cx-line-strong: rgba(157, 255, 178, 0.38);
  --cx-text: #e7f6ec;
  --cx-muted: #8eab98;
  --cx-faint: #6d8878;
  --cx-accent: #9dffb2;
  --cx-on: #07110c;
  --cx-amber: #e6c07b;
  --cx-weak: #e08b7a;
  --cx-radius: 4px;
  --cx-sans: "IBM Plex Sans", system-ui, sans-serif;
  --cx-mono: "IBM Plex Mono", ui-monospace, monospace;
  --lp-level: 0;

  position: relative;
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
  background:
    linear-gradient(180deg, rgba(157, 255, 178, 0.04), transparent 220px),
    var(--cx-bg);
  color: var(--cx-text);
  font-family: var(--cx-sans);
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
}

.cx-shell *,
.cx-shell *::before,
.cx-shell *::after {
  box-sizing: border-box;
}

.cx-shell [hidden] {
  display: none !important;
}

.cx-shell p,
.cx-shell h1,
.cx-shell h2,
.cx-shell ol {
  margin: 0;
}

.cx-shell [data-when]:not([hidden]) {
  animation: cx-fade 0.18s ease-out both;
}

.cx-display {
  font-weight: 500;
  letter-spacing: -0.02em;
}

.cx-eyebrow {
  margin: 0;
  font-family: var(--cx-mono);
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--cx-accent);
}

.cx-topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 16px;
  min-height: 64px;
  padding: 12px 20px;
  border-bottom: 1px solid var(--cx-line);
  background: rgba(7, 17, 12, 0.92);
  backdrop-filter: blur(10px);
}

.cx-brand {
  color: var(--cx-text);
  font-weight: 600;
  letter-spacing: 0.08em;
  text-decoration: none;
}

.cx-brand__mark {
  margin-left: 8px;
  color: var(--cx-accent);
  font-family: var(--cx-mono);
  font-size: 12px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.cx-nav-link,
.cx-topbar__name,
.cx-player__name {
  color: var(--cx-text);
  text-decoration: none;
}

.cx-nav-link {
  font-family: var(--cx-mono);
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--cx-muted);
}

.cx-topbar__title {
  min-width: 0;
  text-align: center;
}

.cx-topbar__name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 14px;
}

.cx-player {
  display: flex;
  align-items: center;
  gap: 8px;
}

.cx-player__avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border: 1px solid var(--cx-line-strong);
  color: var(--cx-accent);
  font-family: var(--cx-mono);
  font-size: 12px;
}

.cx-icon-btn,
.cx-chip-btn,
.cx-play,
.cx-mic,
.cx-action,
.cx-btn {
  font: inherit;
  cursor: pointer;
}

.cx-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: 1px solid var(--cx-line);
  background: transparent;
  color: var(--cx-text);
}

.cx-icon-btn svg,
.cx-chip-btn svg,
.cx-action__arrow {
  width: 16px;
  height: 16px;
}

.cx-main {
  width: min(1120px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 64px;
}

.cx-alert {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 18px;
  padding: 10px 12px;
  border: 1px solid rgba(224, 139, 122, 0.5);
  color: #f3c7be;
}

.cx-alert--notice {
  border-color: var(--cx-line-strong);
  color: var(--cx-text);
}

.cx-hero {
  max-width: 680px;
  margin-bottom: 28px;
}

.cx-hero__title,
.cx-summary__title,
.cx-brief__title,
.cx-start__title {
  margin-top: 8px;
  font-size: clamp(32px, 5vw, 52px);
  line-height: 1.05;
}

.cx-hero__lead,
.cx-summary__lead,
.cx-brief__lead {
  margin-top: 12px;
  max-width: 62ch;
  color: var(--cx-muted);
  line-height: 1.55;
}

.cx-card {
  border: 1px solid var(--cx-line);
  background: var(--cx-surface);
}

.cx-empty {
  padding: 28px;
}

.cx-empty p + p,
.cx-empty .cx-btn {
  margin-top: 12px;
}

.cx-picker,
.cx-access {
  display: grid;
  gap: 20px;
}

@media (min-width: 900px) {
  .cx-picker {
    grid-template-columns: minmax(0, 1.4fr) minmax(280px, 0.8fr);
    align-items: start;
  }
}

.cx-choices {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 0;
  border: 0;
}

.cx-choice {
  display: block;
}

.cx-choice input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.cx-choice__card {
  display: grid;
  grid-template-columns: 92px minmax(0, 1fr);
  min-height: 92px;
  border: 1px solid var(--cx-line);
  background: var(--cx-surface);
}

.cx-choice input:checked + .cx-choice__card {
  border-color: var(--cx-accent);
  box-shadow: inset 3px 0 0 var(--cx-accent);
}

.cx-choice__media {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #07110c;
  color: var(--cx-accent);
  overflow: hidden;
}

.cx-choice__media img,
.cx-choice__media svg {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.cx-choice__media svg {
  width: 28px;
  height: 28px;
}

.cx-choice__check {
  position: absolute;
  top: 8px;
  right: 8px;
  display: none;
  color: var(--cx-on);
  background: var(--cx-accent);
}

.cx-choice input:checked + .cx-choice__card .cx-choice__check {
  display: inline-flex;
}

.cx-choice__body {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 4px;
  min-width: 0;
  padding: 12px 14px;
}

.cx-choice__title,
.cx-score__title {
  font-size: 16px;
}

.cx-choice__description,
.cx-choice__meta,
.cx-brief__context,
.cx-summary__note,
.cx-badge__note {
  color: var(--cx-muted);
  line-height: 1.45;
}

.cx-choice__meta,
.cx-badge__note,
.cx-summary__note {
  font-size: 13px;
}

.cx-start {
  padding: 22px;
}

.cx-start__steps {
  display: grid;
  gap: 10px;
  margin: 16px 0;
  padding: 0;
  list-style: none;
  color: var(--cx-muted);
}

.cx-start__steps li {
  display: flex;
  gap: 10px;
}

.cx-start__steps span,
.cx-action__index,
.cx-score__index {
  display: inline-flex;
  flex: none;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border: 1px solid var(--cx-line-strong);
  font-family: var(--cx-mono);
  font-size: 11px;
  color: var(--cx-accent);
}

.cx-label {
  display: block;
  margin-bottom: 8px;
  font-family: var(--cx-mono);
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--cx-faint);
}

.cx-field {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--cx-line-strong);
  background: #07110c;
  color: var(--cx-text);
  font: inherit;
}

.cx-field:focus,
.cx-btn:focus-visible,
.cx-icon-btn:focus-visible,
.cx-play:focus-visible,
.cx-mic:focus-visible,
.cx-chip-btn:focus-visible,
.cx-action:focus-visible,
.cx-choice input:focus-visible + .cx-choice__card {
  outline: 2px solid var(--cx-accent);
  outline-offset: 2px;
}

.cx-start__submit {
  margin-top: 16px;
}

.cx-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 16px;
  border: 1px solid transparent;
  text-decoration: none;
}

.cx-btn svg {
  width: 16px;
  height: 16px;
}

.cx-btn--primary {
  background: var(--cx-accent);
  color: var(--cx-on);
}

.cx-btn--ghost {
  border-color: var(--cx-line-strong);
  background: transparent;
  color: var(--cx-text);
}

.cx-btn--block {
  width: 100%;
}

.cx-scene {
  display: grid;
  gap: 14px;
}

.cx-trail {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.cx-trail__dots {
  display: flex;
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.cx-dot {
  width: 8px;
  height: 8px;
  background: var(--cx-surface-2);
}

.cx-dot--strong {
  background: var(--cx-accent);
}

.cx-dot--weak {
  background: var(--cx-amber);
}

.cx-dot--current {
  background: transparent;
  box-shadow: inset 0 0 0 1px var(--cx-accent);
}

.cx-layout {
  display: grid;
  gap: 14px;
}

@media (min-width: 1024px) {
  .cx-layout {
    grid-template-columns: minmax(0, 1fr) 360px;
    grid-template-areas:
      "screen brief"
      "screen dock";
  }

  .cx-screen { grid-area: screen; }
  .cx-brief { grid-area: brief; }
  .cx-dock { grid-area: dock; }
}

.cx-screen {
  position: relative;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  border: 1px solid var(--cx-line);
  background: #000;
}

.cx-screen.is-portrait {
  aspect-ratio: 9 / 16;
  width: auto;
  max-width: 100%;
  height: min(72dvh, 760px);
  justify-self: center;
}

.cx-screen video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #000;
}

.cx-shell[data-state="intro"] .cx-screen video,
.cx-shell[data-state="processing"] .cx-screen video {
  filter: brightness(0.45);
}

.cx-shell[data-state="ready"] .cx-scene[data-scene-kind="decision"] .cx-screen video,
.cx-shell[data-state="recording"] .cx-scene[data-scene-kind="decision"] .cx-screen video {
  filter: brightness(0.62);
}

.cx-screen__overlay,
.cx-screen__placeholder,
.cx-screen__buffering {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 24px;
  text-align: center;
}

.cx-screen__buffering {
  display: none;
  pointer-events: none;
}

.cx-screen.is-buffering .cx-screen__buffering {
  display: flex;
}

.cx-screen__placeholder {
  color: var(--cx-muted);
  background: var(--cx-surface);
}

.cx-play {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 72px;
  height: 72px;
  border: 0;
  background: var(--cx-accent);
  color: var(--cx-on);
}

.cx-play svg {
  width: 26px;
  height: 26px;
  margin-left: 3px;
}

.cx-play-hint,
.cx-dock__hint {
  color: var(--cx-muted);
  font-size: 13px;
}

.cx-screen__corner {
  position: absolute;
  right: 12px;
  bottom: 16px;
  z-index: 3;
}

.cx-screen__corner--top {
  top: 12px;
  bottom: auto;
}

.cx-chip-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 32px;
  padding: 0 12px;
  border: 1px solid var(--cx-line-strong);
  background: rgba(7, 17, 12, 0.8);
  color: var(--cx-text);
}

.cx-progress {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 3;
  height: 3px;
  background: rgba(255, 255, 255, 0.12);
}

.cx-progress__bar {
  height: 100%;
  width: 100%;
  transform-origin: left center;
  transform: scaleX(var(--lp-progress, 0));
  background: var(--cx-accent);
}

.cx-spinner {
  width: 32px;
  height: 32px;
  border: 2px solid rgba(157, 255, 178, 0.2);
  border-top-color: var(--cx-accent);
  border-radius: 50%;
  animation: cx-spin 0.8s linear infinite;
}

.cx-spinner--sm {
  width: 16px;
  height: 16px;
}

.cx-actions {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: 10px;
  padding: 16px;
  background: linear-gradient(to top, rgba(7, 17, 12, 0.94), rgba(7, 17, 12, 0.2) 58%, transparent 74%);
}

.cx-actions__label {
  font-family: var(--cx-mono);
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--cx-accent);
}

.cx-actions__list,
.cx-scores {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.cx-actions__list {
  max-height: 70%;
  overflow: auto;
}

.cx-action {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 48px;
  padding: 10px 12px;
  border: 1px solid rgba(157, 255, 178, 0.28);
  background: rgba(7, 17, 12, 0.78);
  color: var(--cx-text);
  text-align: left;
}

.cx-action:hover,
.cx-action.is-chosen {
  border-color: var(--cx-accent);
  background: rgba(157, 255, 178, 0.14);
}

.cx-action__label {
  flex: 1;
}

.cx-shell[data-state="processing"] .cx-action {
  pointer-events: none;
}

.cx-shell[data-state="processing"] .cx-action:not(.is-chosen) {
  opacity: 0.4;
}

.cx-brief,
.cx-dock {
  padding: 18px;
}

.cx-goal {
  display: flex;
  gap: 12px;
  margin-top: 16px;
  padding: 12px;
  background: var(--cx-surface-2);
}

.cx-goal__icon {
  display: inline-flex;
  color: var(--cx-accent);
}

.cx-goal__icon svg {
  width: 18px;
  height: 18px;
}

.cx-goal__label {
  font-family: var(--cx-mono);
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--cx-faint);
}

.cx-goal__text {
  margin-top: 4px;
  line-height: 1.45;
}

.cx-recap {
  display: flex;
  gap: 8px;
  margin-top: 14px;
  color: var(--cx-muted);
  font-size: 13px;
  line-height: 1.45;
}

.cx-recap__dot {
  flex: none;
  width: 8px;
  height: 8px;
  margin-top: 5px;
  background: var(--cx-amber);
}

.cx-recap--strong .cx-recap__dot {
  background: var(--cx-accent);
}

.cx-recap--blocked .cx-recap__dot {
  background: var(--cx-weak);
}

.cx-dock {
  display: flex;
  align-items: center;
  gap: 16px;
}

.cx-dock__text {
  flex: 1;
  min-width: 0;
}

.cx-dock__status {
  font-weight: 500;
}

.cx-dock__transcript,
.cx-dock__error {
  margin-top: 8px;
}

.cx-dock__transcript:empty,
.cx-dock__error:empty {
  display: none;
}

.cx-dock__error {
  color: #f3c7be;
}

.cx-kbd {
  display: inline-block;
  padding: 0 5px;
  border: 1px solid var(--cx-line-strong);
  font-family: var(--cx-mono);
  font-size: 11px;
}

@media (hover: none) {
  .cx-kbd-hint { display: none; }
}

.cx-mic {
  position: relative;
  display: inline-flex;
  flex: none;
  align-items: center;
  justify-content: center;
  width: 64px;
  height: 64px;
  border: 0;
  background: var(--cx-accent);
  color: var(--cx-on);
}

.cx-mic svg {
  position: relative;
  z-index: 1;
  width: 24px;
  height: 24px;
}

.cx-mic__halo {
  position: absolute;
  inset: 0;
  border: 2px solid var(--cx-accent);
  opacity: 0;
  pointer-events: none;
  transform: scale(calc(1.08 + var(--lp-level) * 0.35));
}

.cx-mic .cx-icon-stop,
.cx-mic .cx-icon-wait {
  display: none;
}

.cx-shell[data-state="recording"] .cx-mic {
  background: var(--cx-weak);
  color: #fff;
}

.cx-shell[data-state="recording"] .cx-mic__halo {
  opacity: 0.85;
}

.cx-shell[data-state="recording"] .cx-mic .cx-icon-mic,
.cx-shell[data-state="processing"] .cx-mic .cx-icon-mic {
  display: none;
}

.cx-shell[data-state="recording"] .cx-mic .cx-icon-stop,
.cx-shell[data-state="processing"] .cx-mic .cx-icon-wait {
  display: block;
}

.cx-shell[data-state="processing"] .cx-mic .cx-icon-wait {
  animation: cx-spin 0.8s linear infinite;
}

.cx-shell[data-state="intro"] .cx-mic,
.cx-shell[data-state="watching"] .cx-mic,
.cx-shell[data-state="processing"] .cx-mic {
  background: var(--cx-surface-2);
  color: var(--cx-faint);
}

.cx-rec-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  margin-right: 6px;
  background: var(--cx-weak);
}

.cx-result {
  position: fixed;
  top: 76px;
  left: 50%;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 12px;
  width: calc(100% - 32px);
  max-width: 520px;
  padding: 12px 14px;
  border: 1px solid var(--cx-line-strong);
  border-left: 3px solid var(--cx-accent);
  background: rgba(16, 26, 21, 0.97);
  opacity: 0;
  visibility: hidden;
  transform: translate(-50%, -8px);
}

.cx-result.is-open {
  opacity: 1;
  visibility: visible;
  transform: translate(-50%, 0);
}

.cx-result[data-outcome="weak"],
.cx-result[data-outcome="unclear"],
.cx-result[data-outcome="miss"] {
  border-left-color: var(--cx-amber);
}

.cx-result[data-outcome="blocked"] {
  border-left-color: var(--cx-weak);
}

.cx-result__icon svg,
.cx-result__icon .cx-fb-icon-loading {
  display: none;
  width: 18px;
  height: 18px;
}

.cx-result[data-outcome="strong"] .cx-fb-icon-match,
.cx-result[data-outcome="acceptable"] .cx-fb-icon-match,
.cx-result[data-outcome="briefing"] .cx-fb-icon-match,
.cx-result[data-outcome="done"] .cx-fb-icon-match,
.cx-result[data-outcome="weak"] .cx-fb-icon-miss,
.cx-result[data-outcome="unclear"] .cx-fb-icon-miss,
.cx-result[data-outcome="blocked"] .cx-fb-icon-blocked,
.cx-result[data-outcome="loading"] .cx-fb-icon-loading {
  display: block;
}

.cx-result__title {
  font-weight: 500;
}

.cx-result__detail {
  color: var(--cx-muted);
  font-size: 13px;
}

.cx-result__scores:empty {
  display: none;
}

.cx-pool {
  position: fixed;
  top: -10px;
  left: -10px;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

.cx-pool__status {
  position: fixed;
  bottom: 16px;
  left: 50%;
  z-index: 25;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border: 1px solid var(--cx-line);
  background: rgba(7, 17, 12, 0.94);
  color: var(--cx-muted);
  font-size: 13px;
  transform: translateX(-50%);
}

.cx-summary {
  display: grid;
  justify-items: center;
  text-align: center;
}

.cx-summary__title {
  font-size: clamp(36px, 6vw, 60px);
}

.cx-scoreline {
  margin: 18px 0 8px;
}

.cx-scoreline__value {
  font-family: var(--cx-mono);
  font-size: 64px;
  line-height: 1;
  color: var(--cx-accent);
}

.cx-scoreline__caption,
.cx-stat__label {
  color: var(--cx-faint);
  font-family: var(--cx-mono);
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.cx-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  width: min(520px, 100%);
  margin: 18px 0 28px;
}

.cx-stat {
  padding: 14px 8px;
  border: 1px solid var(--cx-line);
}

.cx-stat__value {
  font-family: var(--cx-mono);
  font-size: 28px;
}

.cx-badge {
  width: min(760px, 100%);
  margin-bottom: 28px;
}

.cx-badge img {
  width: 100%;
  height: auto;
  border: 1px solid var(--cx-line-strong);
}

.cx-badge__actions,
.cx-summary__actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  margin-top: 14px;
}

.cx-summary__actions form {
  margin: 0;
}

.cx-scores {
  width: min(720px, 100%);
  margin-top: 8px;
  text-align: left;
}

.cx-score {
  padding: 16px;
}

.cx-score--strong {
  box-shadow: inset 3px 0 0 var(--cx-accent);
}

.cx-score--weak {
  box-shadow: inset 3px 0 0 var(--cx-amber);
}

.cx-score__head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.cx-score__head p {
  display: flex;
  align-items: center;
  gap: 8px;
}

.cx-score__quote {
  margin-top: 10px;
}

.cx-score__meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.cx-pill {
  display: inline-flex;
  padding: 3px 8px;
  border: 1px solid var(--cx-line);
  font-family: var(--cx-mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--cx-muted);
}

.cx-pill--strong {
  border-color: var(--cx-accent);
  color: var(--cx-accent);
}

.cx-pill--weak {
  border-color: var(--cx-amber);
  color: var(--cx-amber);
}

.cx-summary .cx-summary__note {
  margin-top: 8px;
  text-align: left;
}

@keyframes cx-fade {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes cx-spin {
  to { transform: rotate(360deg); }
}

@media (prefers-reduced-motion: reduce) {
  .cx-shell *,
  .cx-shell *::before,
  .cx-shell *::after {
    animation: none !important;
    transition: none !important;
  }
}
