/* ═══════════════════════════════════════════════════════════════
   SHIELD AI — Components
   Panels, Cards, Buttons, Inputs, Progress, Milestones, Badges
   ═══════════════════════════════════════════════════════════════ */

/* ── Panel ── */
.panel {
  background: var(--bg-1);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: var(--space-2) var(--space-3); /* S-016: tighter default padding */
  transition: background 200ms ease, border-color 200ms ease; /* S-046 */
}

/* S-046: Panel hover depth — one shade lift */
.panel:hover {
  background: var(--bg-2);
  border-color: var(--line-strong);
}

/* S-165: Panel hover suppressed when hovering child cards */
.panel:has(.report-card:hover),
.panel:has(.job-card:hover),
.panel:has(.stat-card:hover) {
  background: var(--bg-1);
  border-color: var(--line);
}

/* S-164: Animation budget — quiet secondary animations during analysis */
body:has(.map-panel.is-analyzing) .connection-dot.connected {
  animation: none;
  opacity: 1;
}

body:has(.map-panel.is-analyzing) .milestone.active {
  animation: none;
  box-shadow: 0 0 4px 0 var(--accent-dim);
}

.map-panel:hover {
  background: var(--bg-1); /* map stays put — already the hero */
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline; /* S-015: baseline alignment for mixed font sizes */
  gap: var(--space-2);
  margin-bottom: var(--space-3); /* S-015: more breathing room */
}

.panel-header .badge {
  flex-shrink: 0;
  margin-top: 2px; /* S-015: visual alignment nudge */
}

.compact-panel {
  padding: var(--space-1) var(--space-2); /* S-016: tighter compact */
}

/* ── S-036 / S-205: Masthead — classified header with line-draw boot ── */
.masthead {
  background: var(--bg-0);
  position: relative;
}
.masthead::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--accent);
  transform-origin: left;
  animation: line-draw 600ms ease-out 100ms both;
}

/* S-176: Masthead heading letter-spacing transition on hover */
.masthead h1 {
  font-size: var(--text-2xl);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  transition: letter-spacing 300ms ease;
}
.masthead:hover h1 { letter-spacing: 0.10em; }

/* S-080: UTC clock */
.utc-clock {
  font: 400 var(--text-xs)/1 var(--font-mono);
  color: var(--text-tertiary);
  letter-spacing: 0.06em;
  margin-top: var(--space-1);
}

/* ── Eyebrow label ── */
.eyebrow {
  margin: 0 0 var(--space-2);
  font: 500 var(--text-xs)/1.2 var(--font-display);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-secondary); /* readable by default */
}

.lede {
  color: var(--text-secondary);
  line-height: 1.4;
  font-size: var(--text-sm);
}

/* ── Cards ── */
.card {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--bg-2);
  padding: var(--space-2) var(--space-3);
  min-width: 0;
  overflow: hidden;
  transition: border-color var(--transition-fast);
}

.card:hover {
  border-color: var(--line-strong);
}

.stat-card,
.report-card,
.job-card,
.widget-card,
.scene-panel-card,
.narrative-card,
.mini-card {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--bg-2);
  padding: var(--space-2) var(--space-3);
  min-width: 0;
  min-height: 48px;
  overflow: hidden;
  transition: border-color var(--transition-fast);
}

.stat-card:hover {
  border-color: var(--line-strong);
}

.stat-card strong,
.report-card strong,
.job-card strong,
/* S-098: Tone-aware widget eyebrows */
.widget-card.tone-critical .eyebrow,
.widget-card.tone-high .eyebrow,
.widget-card.tone-rival .eyebrow { color: var(--risk-high); }
.widget-card.tone-medium .eyebrow,
.widget-card.tone-warning .eyebrow { color: var(--accent); }
.widget-card.tone-low .eyebrow,
.widget-card.tone-ally .eyebrow { color: var(--risk-low); }

.widget-card strong {
  display: block;
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: 700;
  margin-top: var(--space-1);
  overflow-wrap: anywhere;
}

/* ── Tone stripes (left border) — S-007: weight escalation ── */
.tone-low,
.tone-ally {
  border-left: 2px solid var(--risk-low);
}

.tone-medium,
.tone-warning {
  border-left: 3px solid var(--risk-medium);
}

.tone-high {
  border-left: 4px solid var(--risk-high);
}

.tone-critical,
.tone-rival {
  border-left: 5px solid var(--risk-critical);
  background: rgba(220, 38, 38, 0.03); /* barely tinted — felt, not seen */
}

/* ── Narrative card — S-002: typewriter reveal ── */
@keyframes typewriter-reveal {
  from { clip-path: inset(0 100% 0 0); }
  to { clip-path: inset(0 0 0 0); }
}

/* ── S-037: Narrative card — classified briefing feel ── */
.narrative-card:not(.empty-state) {
  animation: typewriter-reveal 800ms steps(40, end) 400ms both; /* S-094: 400ms dramatic pause */
  background: var(--bg-0);
  border-left: 3px solid var(--accent);
  padding: var(--space-4) var(--space-4) var(--space-4) var(--space-5);
  position: relative;
}

.narrative-card:not(.empty-state)::before {
  content: 'ASSESSMENT';
  position: absolute;
  top: var(--space-2);
  right: var(--space-3);
  font: 500 8px/1 var(--font-display);
  letter-spacing: 0.2em;
  color: var(--text-tertiary);
  text-transform: uppercase;
}

/* S-133: Paragraph stagger in narrative */
@keyframes para-reveal {
  from { opacity: 0; transform: translateY(3px); }
  to { opacity: 1; transform: translateY(0); }
}

.narrative-card:not(.empty-state) p { opacity: 0; animation: para-reveal 400ms ease-out forwards; }
.narrative-card:not(.empty-state) .eyebrow { animation-delay: 200ms; }
.narrative-card:not(.empty-state) h3 { opacity: 0; animation: para-reveal 400ms ease-out 400ms forwards; }
.narrative-card:not(.empty-state) p:nth-child(2) { animation-delay: 400ms; }
.narrative-card:not(.empty-state) p:nth-child(3) { animation-delay: 700ms; }
.narrative-card:not(.empty-state) p:nth-child(4) { animation-delay: 1000ms; }

.narrative-card h3 {
  margin: 0 0 var(--space-2);
  font-size: var(--text-lg);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 400; /* S-012: calm default */
}

/* S-012: risk level typography weight */
.tone-medium .narrative-card h3 { font-weight: 500; }
.tone-high .narrative-card h3,
.tone-critical .narrative-card h3 {
  font-weight: 700;
  letter-spacing: 0.06em;
}

.narrative-card p:last-child {
  margin-bottom: 0;
  line-height: 1.45;
}

/* S-104: Copy button — appears on hover */
.copy-btn {
  position: absolute;
  top: var(--space-2);
  right: var(--space-2);
  width: auto;
  padding: 2px 8px;
  font-size: var(--text-xs);
  opacity: 0;
  transition: opacity 150ms ease;
  z-index: 1;
}

.narrative-card:hover .copy-btn { opacity: 1; }
.copy-btn:hover { background: var(--accent) !important; color: var(--bg-0) !important; }

/* S-191: Assessment timestamp */
.assessment-ts {
  font: 400 var(--text-xs)/1 var(--font-mono);
  color: var(--text-tertiary);
  margin-bottom: var(--space-2);
  letter-spacing: 0.04em;
}

/* S-192: Word count */
.word-count {
  font: 400 var(--text-xs)/1 var(--font-mono);
  color: var(--text-tertiary);
  text-align: right;
  margin-top: var(--space-2);
  opacity: 0.5;
}

/* ── Scene panels ── */
/* S-086: Numbered evidence list */
.scene-panel-card ul {
  margin: 0;
  padding-left: 20px;
  list-style: decimal;
  color: var(--text-primary);
  line-height: 1.35;
  font-size: var(--text-sm);
}

.scene-panel-card ul li::marker {
  color: var(--text-tertiary);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
}

.scene-panel-card li + li {
  margin-top: var(--space-1);
}

/* S-057: Evidence list hover guide */
.scene-panel-card li {
  padding: var(--space-1) 0;
  padding-left: var(--space-2);
  border-left: 2px solid transparent;
  transition: border-color 150ms ease, color 150ms ease;
}

.scene-panel-card li:hover {
  border-left-color: var(--accent-dim);
  color: var(--text-primary);
}

/* S-150: BLUF — first line of scenario items is bold */
.scene-panel-card li::first-line {
  font-weight: 600;
  color: var(--text-primary);
}

/* S-154: Click-to-expand evidence items */
.scene-panel-card li { cursor: pointer; }
.scene-panel-card li.expanded { -webkit-line-clamp: unset; display: block; }
/* S-167: Asymmetric fade timing — exit fast, entrance slow */
.scene-panel-card li::after { transition: opacity 300ms ease; }
.scene-panel-card li.expanded::after { opacity: 0; transition: opacity 150ms ease; }

/* S-153: Copy flash on source element */
@keyframes copy-flash {
  0% { outline: 2px solid var(--accent); outline-offset: 2px; }
  100% { outline: 2px solid transparent; outline-offset: 2px; }
}
.just-copied { animation: copy-flash 400ms ease-out; }

/* ── Job cards ── */
/* S-117: Job card — always 3px left border, color transitions */
.job-card {
  cursor: pointer;
  border-left: 3px solid transparent;
  transition: border-color 200ms ease, background 200ms ease;
}

.job-card:hover {
  border-color: var(--line-active);
  background: var(--bg-3);
}

/* S-052: Job card select pulse */
@keyframes card-select {
  0% { border-left-color: var(--accent); box-shadow: inset 3px 0 8px -4px var(--accent-dim); }
  100% { border-left-color: var(--accent); box-shadow: none; }
}

.job-card.active {
  border-left-color: var(--accent); /* S-117: color only, no width change */
  background: var(--bg-3);
  animation: card-select 500ms ease-out;
}

/* ── Report cards ── */
/* S-055: Report card hover expansion */
.report-card {
  transition: max-height 300ms ease;
  max-height: 160px;
  overflow: hidden;
}

.report-card:hover {
  max-height: 240px;
}

/* S-096: Time crossfade — relative ↔ absolute on hover */
.report-time { position: relative; }
.time-rel, .time-abs { transition: opacity 200ms ease; }
.time-abs { position: absolute; right: 0; opacity: 0; }
.report-card:hover .time-rel { opacity: 0; }
.report-card:hover .time-abs { opacity: 1; }

.report-card:hover .clamp-4 {
  -webkit-line-clamp: 7;
}

/* S-128+S-130: Report cards — clickable, cascading, hoverable */
.report-card {
  cursor: pointer;
  animation: card-arrive 200ms ease-out both;
}
.report-card:hover {
  border-color: var(--line-active);
  background: var(--bg-3);
}
.report-card:active { transform: scale(0.99); }

/* S-141: Selected report card (keyboard navigation) */
.report-card.selected {
  border-color: var(--accent);
  background: var(--bg-3);
}

/* S-169: Report card zebra stripes */
.report-card:nth-child(even) {
  background: rgba(25, 25, 29, 0.7);
}

/* S-170: Report summary BLUF — first line highlighted */
.report-card .clamp-6::first-line {
  color: var(--text-primary);
  font-weight: 500;
}

/* S-171: Primary widget value is larger */
.widget-primary strong {
  font-size: var(--text-xl);
}
.report-card:nth-child(1) { animation-delay: 0ms; }
.report-card:nth-child(2) { animation-delay: 50ms; }
.report-card:nth-child(3) { animation-delay: 100ms; }
.report-card:nth-child(4) { animation-delay: 150ms; }
.report-card:nth-child(5) { animation-delay: 200ms; }
.report-card:nth-child(6) { animation-delay: 250ms; }
.report-card:nth-child(7) { animation-delay: 300ms; }
.report-card:nth-child(8) { animation-delay: 350ms; }

.report-card .panel-header {
  margin-bottom: var(--space-1);
}

/* S-056: Value change flash */
@keyframes value-flash {
  0% { border-color: var(--accent); }
  100% { border-color: var(--line); }
}

.stat-card.value-changed {
  animation: value-flash 800ms ease-out;
}

/* S-054: Panel description */
.panel-desc {
  font: 400 var(--text-xs)/1.3 var(--font-body);
  color: var(--text-tertiary);
  margin: calc(-1 * var(--space-1)) 0 var(--space-2) 0;
  opacity: 0.7;
}

/* ── Risk tag / Badge ── */
.risk-tag,
.badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  border-radius: var(--radius-pill);
  padding: 3px 8px;
  font: 500 var(--text-xs)/1 var(--font-display);
  letter-spacing: 0.04em;
}

/* S-068: Risk tag pulse on render */
@keyframes tag-arrive {
  0% { background: var(--accent); color: var(--bg-0); }
  100% { background: var(--accent-dim); color: var(--accent); }
}

.risk-tag {
  background: var(--accent-dim);
  color: var(--accent);
  animation: tag-arrive 600ms ease-out;
}

.badge {
  background: var(--bg-3);
  color: var(--text-secondary);
  border: 1px solid var(--line);
}

/* S-082: Job badge pulse when active */
/* S-178: Badge ping ring */
@keyframes badge-ping {
  0% { box-shadow: 0 0 0 0 var(--accent-dim); }
  70% { box-shadow: 0 0 0 6px transparent; }
  100% { box-shadow: 0 0 0 6px transparent; }
}

.badge.is-active {
  animation: badge-ping 2s ease-out infinite;
}

.badge.is-active::before {
  content: '';
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  margin-right: 6px;
  vertical-align: middle;
  animation: heartbeat 2s ease-in-out infinite;
}

/* ── Empty / Muted states ── */
/* ── S-038: Empty states — invitation, not a grave ── */
.empty-state,
.muted-card {
  color: var(--text-secondary);
  font-style: normal; /* not italic — italic reads as error */
  padding: var(--space-6) var(--space-4);
  text-align: center;
  border: 1px solid var(--line); /* solid, not dashed */
  border-radius: var(--radius-sm);
  background: transparent;
  font-size: var(--text-sm);
  font-family: var(--font-body);
}

/* ── Buttons — S-010: border emphasis hover ── */
button {
  width: 100%;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: var(--space-2) var(--space-4);
  font: 600 var(--text-base)/1.2 var(--font-display);
  letter-spacing: 0.02em;
  cursor: pointer;
  background: var(--accent);
  color: var(--bg-0);
  transition: background 120ms ease, border-color 120ms ease;
}

button:hover:not(:disabled) {
  background: var(--accent-hover);
  border-color: var(--accent);
  filter: none;
  transform: none;
}

button:active:not(:disabled) {
  transform: scale(0.98);
  transition: transform 60ms ease;
}

/* S-010: specific primary CTA emphasis */
#run-analysis:hover:not(:disabled) {
  border-color: var(--accent);
}

/* S-040: Analyze button — primary CTA, full width */
#run-analysis {
  margin-top: var(--space-3);
  width: 100%;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 1px;
  padding: 14px 20px;
  text-transform: uppercase;
  border-radius: 4px;
}

/* S-177: Disabled button — desaturated, not dead */
button:disabled {
  opacity: 0.7;
  filter: saturate(0.3);
  cursor: not-allowed;
}

button.ghost {
  background: var(--bg-2);
  color: var(--text-primary);
  border: 1px solid var(--line);
}

/* S-107: Ghost button amber left edge on hover */
button.ghost:hover {
  border-color: var(--line-active);
  border-left-color: var(--accent-dim);
  border-left-width: 2px;
  padding-left: calc(var(--space-4) - 1px);
  background: var(--bg-3);
}

/* ── Inputs ── */
textarea,
input[type="text"],
input[type="number"],
select {
  width: 100%;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  padding: var(--space-2) var(--space-3);
  font: inherit;
  font-size: var(--text-base);
  color: var(--text-primary);
  background: var(--bg-0);
  transition: border-color var(--transition-fast);
}

/* S-121: Auto-expand textarea */
textarea {
  resize: none;
  overflow: hidden;
  min-height: 60px;
  max-height: 200px;
  transition: height 100ms ease, border-color 200ms ease, box-shadow 200ms ease, background 200ms ease, padding 200ms ease;
}

/* S-122: Character counter */
.char-count {
  display: block;
  text-align: right;
  font: 400 var(--text-xs)/1 var(--font-mono);
  color: var(--text-tertiary);
  margin-top: 2px;
  opacity: 0;
  transition: opacity 200ms ease;
  height: 14px;
}

/* S-123: Range slider tooltip */
.range-wrap { position: relative; }
.range-tooltip {
  position: absolute;
  top: -28px;
  padding: 2px 6px;
  font: 500 var(--text-xs)/1.2 var(--font-mono);
  color: var(--accent);
  background: var(--bg-0);
  border: 1px solid var(--accent-dim);
  border-radius: var(--radius-sm);
  white-space: nowrap;
  opacity: 0;
  transition: opacity 150ms ease;
  pointer-events: none;
  transform: translateX(-50%);
}
.range-wrap:hover .range-tooltip,
.range-tooltip.visible { opacity: 1; }

textarea:focus {
  background: rgba(0, 0, 0, 0.3); /* sinks deeper */
  padding: var(--space-3); /* slightly more generous when focused */
}

/* S-179: Amber caret color */
textarea, input[type="text"], input[type="number"] {
  caret-color: var(--accent);
}

input[type="text"],
input[type="number"],
select {
  min-height: auto;
}

textarea:focus,
input:focus,
select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent-dim);
}

/* Keyboard-only focus ring for accessibility */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  box-shadow: 0 0 0 4px var(--accent-glow);
}

/* ── S-041: Placeholder — gentle ghost ── */
::placeholder {
  color: var(--text-tertiary);
  opacity: 0.6;
  font-style: normal;
  font-weight: 400;
}

textarea::placeholder {
  font-family: var(--font-body);
}

/* ── S-044: Range slider — amber track ── */
input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 4px;
  border-radius: var(--radius-pill);
  background: var(--bg-3);
  outline: none;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  border: 2px solid var(--bg-0);
}

input[type="range"]::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  border: 2px solid var(--bg-0);
}

input[type="range"]::-webkit-slider-runnable-track {
  height: 4px;
  border-radius: var(--radius-pill);
}

label {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  font-family: var(--font-display);
  font-weight: 500;
}

/* S-124: Label → input visual thread */
label[for] {
  display: block;
  padding-left: var(--space-2);
  border-left: 2px solid var(--line);
  margin-bottom: var(--space-1);
  transition: border-color 200ms ease;
}

label[for]:hover {
  border-color: var(--accent-dim);
}

/* ── S-051: Custom checkbox ── */
input[type="checkbox"] {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--bg-0);
  cursor: pointer;
  position: relative;
  transition: background 120ms ease, border-color 120ms ease;
  flex-shrink: 0;
}

input[type="checkbox"]:checked {
  background: var(--accent);
  border-color: var(--accent);
}

input[type="checkbox"]:checked::after {
  content: '';
  position: absolute;
  left: 4.5px;
  top: 1.5px;
  width: 5px;
  height: 9px;
  border: solid var(--bg-0);
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

input[type="checkbox"]:hover {
  border-color: var(--accent-dim);
}

.checkbox-row {
  display: flex;
  gap: var(--space-2);
  align-items: center;
  margin: var(--space-1) 0;
  color: var(--text-secondary);
  font-size: var(--text-sm);
}

/* ── Progress bar ── */
/* S-061: Progress bar fused to map bottom */
.progress-wrap {
  margin-top: 0;
  padding: var(--space-2) var(--space-3);
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-top: none;
  border-bottom-left-radius: var(--radius-sm);
  border-bottom-right-radius: var(--radius-sm);
}

.progress-bar {
  height: 4px;
  border-radius: var(--radius-pill);
  background: var(--bg-3);
  overflow: hidden;
  position: relative;
}

.progress-fill {
  height: 100%;
  width: 0;
  background: var(--accent);
  transition: width 200ms ease;
  position: relative;
}

/* S-045: Shimmer sweep on active progress */
.progress-bar.is-active .progress-fill {
  background: linear-gradient(90deg, var(--accent) 0%, var(--accent-hover) 50%, var(--accent) 100%);
  background-size: 200% 100%;
  animation: shimmer 2s ease-in-out infinite;
}

@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.progress-bar.is-active .progress-fill::after {
  content: '';
  position: absolute;
  right: 0;
  top: -3px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent);
  animation: progress-pulse 1.5s ease-in-out infinite;
}

@keyframes progress-pulse {
  0%, 100% { opacity: 0.6; transform: scale(0.8); }
  50% { opacity: 1; transform: scale(1.2); }
}

/* S-058: Green sweep on completion */
@keyframes complete-sweep {
  0% { background: linear-gradient(90deg, var(--status-active) 0%, var(--accent) 0%); }
  100% { background: linear-gradient(90deg, var(--status-active) 100%, var(--accent) 100%); }
}

.progress-bar.is-complete .progress-fill {
  animation: complete-sweep 500ms ease-out forwards;
  background: var(--status-active);
}

.progress-bar.is-complete .progress-fill::after,
.progress-bar.is-failed .progress-fill::after {
  display: none;
}

.progress-bar.is-failed .progress-fill {
  background: var(--status-failed);
}

.progress-meta {
  margin-top: var(--space-2);
  display: flex;
  justify-content: space-between;
  color: var(--text-secondary);
  font: 400 var(--text-sm)/1 var(--font-mono);
}

/* S-140: Fixed-width percentage — no jitter during updates */
.progress-meta span:last-child {
  min-width: 100px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* ── Milestones (stepper pattern) ── */
.job-milestones {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin-top: var(--space-2);
}

/* S-095: Victory thread — green line through completed milestones */
.job-milestones.all-done {
  position: relative;
}

.job-milestones.all-done::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 16px;
  right: 16px;
  height: 1px;
  background: rgba(22, 163, 74, 0.2);
  z-index: 0;
}

.job-milestones.all-done .milestone {
  position: relative;
  z-index: 1;
}

.milestone {
  border-radius: var(--radius-pill);
  padding: 4px 10px;
  font: 500 var(--text-xs)/1 var(--font-display);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border: 1px solid var(--line);
  background: var(--bg-2);
  /* S-047: state change flow */
  transition: color 400ms ease, background 400ms ease, border-color 400ms ease, box-shadow 400ms ease;
  color: var(--text-tertiary);
  position: relative;
}

/* S-089: Milestone fade trail — earlier milestones dimmer */
.milestone.done {
  color: var(--status-active);
  border-color: rgba(22, 163, 74, 0.3);
  background: rgba(22, 163, 74, 0.08);
  opacity: 0.55;
}
.milestone.done ~ .milestone.done { opacity: 0.65; }
.milestone.done ~ .milestone.done ~ .milestone.done { opacity: 0.75; }
.milestone.done ~ .milestone.done ~ .milestone.done ~ .milestone.done { opacity: 0.85; }
.milestone.done + .milestone.active,
.milestone.done:last-of-type { opacity: 1 !important;
}

.milestone.active {
  color: var(--accent);
  border-color: var(--accent-dim);
  background: var(--accent-glow);
  animation: milestone-glow 2s ease-in-out infinite;
}

@keyframes milestone-glow {
  0%, 100% { box-shadow: 0 0 0 0 transparent; }
  50% { box-shadow: 0 0 8px 0 var(--accent-dim); }
}

.milestone.failed {
  color: var(--status-failed);
  border-color: rgba(220, 38, 38, 0.3);
  background: rgba(220, 38, 38, 0.08);
}

/* ── Connection status dot — S-003: heartbeat pulse ── */
.connection-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-left: var(--space-2);
  vertical-align: middle;
}

.connection-dot.connected {
  background: var(--status-active);
  animation: heartbeat 2s ease-in-out infinite;
}

/* S-059: Disconnect urgency pulse */
.connection-dot.disconnected {
  background: var(--status-failed);
  animation: disconnect-pulse 3s ease-in-out infinite;
}

@keyframes disconnect-pulse {
  0%, 100% { opacity: 0.5; }
  50% { opacity: 1; }
}

.masthead:has(.connection-dot.disconnected) .eyebrow {
  animation: text-urgency 4s ease-in-out infinite;
}

@keyframes text-urgency {
  0%, 100% { opacity: 0.7; }
  50% { opacity: 1; }
}

@keyframes heartbeat {
  0%, 100% { transform: scale(1); opacity: 0.9; }
  14% { transform: scale(1.3); opacity: 1; }
  28% { transform: scale(1); opacity: 0.9; }
  42% { transform: scale(1.15); opacity: 1; }
}

/* ── System banner ── */
.system-banner {
  background: var(--accent-glow);
  color: var(--accent);
  border: 1px solid var(--accent-dim);
  border-radius: var(--radius-sm);
  padding: var(--space-2) var(--space-3);
  font: 400 var(--text-sm)/1.4 var(--font-mono);
  animation: banner-slide 300ms ease-out;
}

.system-banner.ok {
  background: rgba(22, 163, 74, 0.06);
  color: var(--status-active);
  border-color: rgba(22, 163, 74, 0.2);
}

@keyframes banner-slide {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ── Stats grid ── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--space-1); /* S-017: tight gaps between related items */
}

/* S-069: Stat cards cascade entrance (row by row) */
.stats-grid .stat-card {
  animation: card-arrive 200ms ease-out both;
}
.stats-grid .stat-card:nth-child(1) { animation-delay: 0ms; }
.stats-grid .stat-card:nth-child(2) { animation-delay: 40ms; }
.stats-grid .stat-card:nth-child(3) { animation-delay: 40ms; }
.stats-grid .stat-card:nth-child(4) { animation-delay: 80ms; }
.stats-grid .stat-card:nth-child(5) { animation-delay: 80ms; }
.stats-grid .stat-card:nth-child(6) { animation-delay: 120ms; }
.stats-grid .stat-card:nth-child(7) { animation-delay: 120ms; }

/* ── S-005: Tabular numerals for data alignment ── */
.stat-card strong,
.widget-card strong,
.risk-tag,
.progress-meta,
.badge {
  font-variant-numeric: tabular-nums;
}

/* ── S-013: Stat hero class for critical metrics ── */
.stat-card.stat-hero strong {
  font-size: var(--text-2xl);
  line-height: 1;
  margin-top: var(--space-2);
}

.stat-card.stat-hero {
  grid-column: span 2;
  padding: var(--space-3) var(--space-4);
}

/* S-088: Warm accent on notable stat values */
.stat-card strong.warm { color: var(--accent); }

/* ── Console — S-014: timestamp dimming ── */
#console {
  margin: 0;
  min-height: 160px;
  max-height: 280px;
  overflow: auto;
  border-radius: var(--radius-sm);
  background: var(--bg-0);
  color: var(--accent);
  padding: var(--space-3);
  font: 400 var(--text-sm)/1.6 var(--font-mono);
  border: 1px solid var(--line);
  font-feature-settings: 'tnum' 1; /* S-014: tabular nums for timestamp alignment */
}

#console .log-ts {
  color: var(--text-tertiary);
}

/* S-083: New log indicator when scrolled away */
/* S-174: Log separator between analysis runs */
.log-separator {
  border: none;
  height: 1px;
  background: var(--line-strong);
  margin: var(--space-2) 0;
}

/* S-175: Console expands when dev tab is active */
.dev-tab-content.active #console {
  max-height: 50vh;
  min-height: 200px;
}

.new-log-badge {
  position: sticky;
  top: 0;
  z-index: 1;
  text-align: center;
  padding: 2px 8px;
  font: 500 var(--text-xs)/1.2 var(--font-display);
  color: var(--accent);
  background: var(--bg-0);
  border-bottom: 1px solid var(--accent-dim);
  cursor: pointer;
}

/* ── Clamp utilities ── */
.clamp-3,
.clamp-4,
.clamp-5,
.clamp-6 {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.clamp-3 { -webkit-line-clamp: 4; }
.clamp-4 { -webkit-line-clamp: 6; }
.clamp-5 { -webkit-line-clamp: 8; }
.clamp-6 { -webkit-line-clamp: 10; }

/* ── S-043: Clamp fade — gentle cliff edge ── */
.clamp-3, .clamp-4, .clamp-5, .clamp-6 {
  position: relative;
}

.clamp-3::after, .clamp-4::after, .clamp-5::after, .clamp-6::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 0.8em;
  background: linear-gradient(transparent, var(--bg-2));
  pointer-events: none;
  opacity: 0.7;
}

/* ── Skeleton loading state ── */
@keyframes skeleton-pulse {
  0%, 100% { opacity: 0.4; }
  50% { opacity: 0.7; }
}

.skeleton {
  animation: skeleton-pulse 1.5s ease-in-out infinite;
}

.skeleton strong {
  color: var(--text-tertiary);
}

/* ── Utility ── */
.muted { color: var(--text-secondary); }

.mono-inline { font-family: var(--font-mono); }

.stack-list {
  display: grid;
  gap: var(--space-2);
}

/* ── Overflow wrap on card content ── */
.job-card strong,
.report-card p,
.mini-card strong,
.mini-card p,
.scene-panel-card li,
.narrative-card p,
.badge,
.risk-tag {
  overflow-wrap: anywhere;
}

/* ── Toast notifications ── */
#toast-container {
  position: fixed;
  top: var(--space-4);
  right: var(--space-4);
  z-index: 10000;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  pointer-events: none;
}

.toast {
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-sm);
  font: 500 var(--text-sm)/1.3 var(--font-display);
  border: 1px solid var(--line);
  background: var(--bg-2);
  color: var(--text-primary);
  opacity: 0;
  transform: translateX(20px);
  transition: opacity 200ms ease, transform 200ms ease;
  pointer-events: auto;
  max-width: 360px;
}

.toast.toast-visible {
  opacity: 1;
  transform: translateX(0);
}

/* S-049: Toast timing — urgency through speed */
.toast-error { border-left: 3px solid var(--status-failed); transition-duration: 120ms; }
.toast-success { border-left: 3px solid var(--status-active); transition-duration: 350ms; }
.toast-info { border-left: 3px solid var(--accent); transition-duration: 200ms; }
.toast-warning { border-left: 3px solid var(--warning); transition-duration: 200ms; }

/* S-091: Toast depth stack */
/* S-120: Toast close button */
.toast { position: relative; padding-right: 28px; }
.toast + .toast { margin-top: var(--space-1); }

.toast-close {
  position: absolute;
  top: 50%;
  right: 8px;
  transform: translateY(-50%);
  cursor: pointer;
  color: var(--text-tertiary);
  font-size: 14px;
  line-height: 1;
  opacity: 0;
  transition: opacity 150ms ease;
}

.toast:hover .toast-close { opacity: 1; }
.toast-close:hover { color: var(--text-primary); }
.toast:not(:first-child) { transform: scale(0.97) translateX(0); opacity: 0.8; }
.toast:not(:first-child):not(:nth-child(2)) { transform: scale(0.94) translateX(0); opacity: 0.65; }

/* ── Keyboard shortcuts overlay ── */
#shortcuts-overlay {
  position: fixed;
  inset: 0;
  z-index: 10001;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fade-in 150ms ease;
}

@keyframes fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

.shortcuts-panel {
  max-width: 360px;
  width: 90%;
  background: var(--bg-1);
}

.shortcuts-panel table {
  width: 100%;
  border-collapse: collapse;
  margin-top: var(--space-2);
}

.shortcuts-panel td {
  padding: var(--space-1) var(--space-2);
  font: 400 var(--text-sm)/1.4 var(--font-body);
  color: var(--text-primary);
  border-bottom: 1px solid var(--line);
}

.shortcuts-panel td:first-child {
  text-align: right;
  width: 120px;
  padding-right: var(--space-3);
}

kbd {
  display: inline-block;
  padding: 2px 6px;
  font: 500 var(--text-xs)/1.2 var(--font-mono);
  background: var(--bg-3);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  color: var(--accent);
}

/* ── S-065: Analyze button loading spinner ── */
@keyframes btn-spin {
  to { transform: rotate(360deg); }
}

/* S-119: Generic button loading spinner (works on any button) */
button.is-loading {
  pointer-events: none;
}

button.is-loading::before {
  content: '';
  display: inline-block;
  width: 10px;
  height: 10px;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  animation: btn-spin 600ms linear infinite;
  vertical-align: middle;
  margin-right: 6px;
  opacity: 0.6;
}

/* ── S-066: Print stylesheet — classified document format ── */
@media print {
  body, .shell, .sidebar, .workspace, .panel,
  .narrative-card, .scene-panel-card {
    background: white !important;
    color: black !important;
    border-color: #ddd !important;
  }
  body::before { display: none !important; }

  .sidebar, .map-panel, .dev-tabs, .scene-widgets,
  .progress-wrap, #system-banner, #toast-container,
  #shortcuts-overlay, .grid-2 > section:last-child {
    display: none !important;
  }

  .shell { display: block !important; }
  .grid-2 { display: block !important; }

  .narrative-card {
    padding: 0 !important;
    border: none !important;
    font-size: 12pt !important;
    line-height: 1.6 !important;
    animation: none !important;
    clip-path: none !important;
  }
  .narrative-card::before {
    content: 'SHIELD AI \2014  RISK ASSESSMENT' !important;
    display: block !important;
    font: 700 14pt/1.2 monospace !important;
    letter-spacing: 0.12em !important;
    border-top: 3px solid #d4a019 !important;
    border-bottom: 1px solid #ccc !important;
    padding: 10pt 0 !important;
    margin-bottom: 16pt !important;
    color: black !important;
  }

  .scene-panels { display: block !important; }
  .scene-panel-card {
    break-inside: avoid !important;
    margin-bottom: 10pt !important;
    padding: 8pt !important;
    border: 1px solid #ddd !important;
    background: white !important;
  }
  .scene-panel-card .eyebrow {
    color: #333 !important;
    font-size: 8pt !important;
  }

  @page { margin: 1in; }

  body::after {
    content: 'UNCLASSIFIED // FOR OFFICIAL USE ONLY';
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    text-align: center;
    font: 500 7pt/1 monospace;
    color: #999;
    padding: 4pt 0;
  }
}

/* ── S-100: The Signature ── */
#signature-overlay {
  position: fixed;
  inset: 0;
  z-index: 10001;
  background: rgba(0, 0, 0, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fade-in 200ms ease;
}

.signature-card {
  max-width: 440px;
  width: 90%;
  padding: var(--space-4) !important;
}

/* ── S-106: Details arrow rotation ── */
details summary { list-style: none; }
details summary::-webkit-details-marker { display: none; }

details summary::before {
  content: '\25b8';
  display: inline-block;
  margin-right: var(--space-2);
  transition: transform 200ms ease;
  font-size: 10px;
  color: var(--text-tertiary);
}

details[open] summary::before {
  transform: rotate(90deg);
}

/* ── S-110: Console severity colors ── */
.log-msg { color: var(--text-secondary); }
.log-error { color: var(--risk-high); }
.log-success { color: var(--status-active); }
