/* Simulation page — read-only animation checker.
   Shares the neutral workspace language defined in app.css: tokens, 1px
   dividers, compact type and a single accent. Every color resolves through a
   --penelopa-* token or an Atlas override (SIM-NF-018). */

/* ---- 1. Page shell and top chrome ---- */

.penelopa-simulation {
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  box-sizing: border-box;
  background: var(--penelopa-bg);
  color: var(--penelopa-text);
}

.penelopa-simulation-chrome {
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: var(--penelopa-bg);
}

.penelopa-simulation-topbar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-height: 2.875rem;
  box-sizing: border-box;
  padding: 0 0.75rem;
  background: var(--penelopa-chrome);
  color: var(--penelopa-text);
  border-bottom: 1px solid var(--penelopa-border);
}

.penelopa-simulation-title {
  margin: 0;
  overflow: hidden;
  color: var(--penelopa-text);
  font-size: 0.8125rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.penelopa-simulation-nav {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  min-width: 0;
}

.penelopa-simulation-back {
  flex: 0 0 auto;
}

.penelopa-simulation-transport {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.125rem;
  min-width: 0;
  margin-inline-start: auto;
}

.penelopa-transport-divider {
  width: 1px;
  height: 1rem;
  margin: 0 0.3125rem;
  background: var(--penelopa-divider);
}

.penelopa-simulation-transport .penelopa-action[aria-pressed="true"] {
  border-color: var(--penelopa-accent);
  background: var(--penelopa-selection);
  color: var(--penelopa-accent-strong);
}

.penelopa-transport-readout {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  margin-inline-start: 0.25rem;
  color: var(--penelopa-text-muted);
}

.penelopa-simulation-status {
  min-width: 4.5rem;
  color: var(--penelopa-text-muted);
  font-size: 0.625rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-align: end;
  text-transform: uppercase;
}

.penelopa-simulation-time {
  min-width: 4.5rem;
  color: var(--penelopa-text-secondary);
  font-family: var(--penelopa-font-mono);
  font-size: 0.71875rem;
  font-variant-numeric: tabular-nums;
  text-align: end;
}

/* ---- 2. Chrome banners ---- */

.penelopa-simulation-error {
  display: flex;
  flex: 0 0 auto;
  align-items: flex-start;
  gap: 0.375rem;
  margin: 0;
  padding: 0.375rem 0.75rem;
  background: var(--penelopa-danger-bg);
  border-bottom: 1px solid var(--penelopa-border);
  color: var(--penelopa-danger-text);
  font-size: 0.71875rem;
  line-height: 1.5;
}

.penelopa-simulation-error > .penelopa-icon {
  margin-top: 0.0625rem;
}

.penelopa-simulation-error > span,
.penelopa-simulation-issues-body {
  min-width: 0;
  overflow-wrap: anywhere;
}

.penelopa-simulation-issues-body p {
  margin: 0;
  font-weight: 600;
}

.penelopa-simulation-issues-body ul {
  margin: 0.125rem 0 0;
  padding-inline-start: 1rem;
}

.penelopa-simulation-save-message {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 0.375rem;
  margin: 0;
  padding: 0.375rem 0.75rem;
  background: var(--penelopa-success-bg);
  border-bottom: 1px solid var(--penelopa-border);
  color: var(--penelopa-success-text);
  font-size: 0.71875rem;
  line-height: 1.5;
}

.penelopa-simulation-save-message.is-error {
  background: var(--penelopa-danger-bg);
  color: var(--penelopa-danger-text);
}

.penelopa-simulation-hint {
  margin: 0;
  color: var(--penelopa-text-muted);
  font-size: 0.6875rem;
  line-height: 1.5;
}

.penelopa-simulation-reduced-motion,
.penelopa-simulation-empty-hint {
  flex: 0 0 auto;
  padding: 0.25rem 0.75rem;
  background: var(--penelopa-chrome);
  border-bottom: 1px solid var(--penelopa-divider);
}

.penelopa-simulation-save-confirm {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
  padding: 0.375rem 0.75rem;
  background: var(--penelopa-warning-bg);
  border-bottom: 1px solid var(--penelopa-border);
  color: var(--penelopa-warning-text);
  font-size: 0.71875rem;
}

.penelopa-simulation-save-confirm-actions {
  display: flex;
  gap: 0.25rem;
}

.penelopa-simulation-dormant {
  flex: 0 0 auto;
  padding: 0.375rem 0.75rem;
  background: var(--penelopa-warning-bg);
  border-bottom: 1px solid var(--penelopa-border);
  color: var(--penelopa-warning-text);
  font-size: 0.71875rem;
}

.penelopa-simulation-dormant-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.penelopa-simulation-dormant-details {
  margin-top: 0.25rem;
}

.penelopa-simulation-dormant-details summary {
  cursor: pointer;
  font-size: 0.6875rem;
}

.penelopa-simulation-dormant-list {
  display: grid;
  gap: 0.125rem;
  margin: 0.25rem 0 0;
  padding: 0;
  list-style: none;
}

.penelopa-simulation-dormant-list li {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  padding: 0.125rem 0;
}

.penelopa-simulation-dormant-id {
  font-family: var(--penelopa-font-mono);
  font-size: 0.6875rem;
}

.penelopa-simulation-dormant-count {
  color: inherit;
  opacity: 0.75;
}

.penelopa-simulation-dormant-list .penelopa-action {
  margin-inline-start: auto;
}

/* ---- 3. Panels ---- */

.penelopa-simulation-tree-panel,
.penelopa-simulation-inspector-panel {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  box-sizing: border-box;
  overflow: hidden;
}

.penelopa-simulation-tree-panel > .penelopa-tree,
.penelopa-simulation-inspector-panel > .penelopa-properties {
  flex: 1 1 auto;
  min-height: 0;
}

.penelopa-simulation-canvas-panel {
  position: relative;
  display: flex;
  flex: 1 1 auto;
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}

.penelopa-simulation-canvas-panel .penelopa-canvas {
  flex: 1 1 auto;
}

.penelopa-canvas-visual {
  width: 100%;
  height: 100%;
}

.penelopa-simulation-canvas-empty {
  position: absolute;
  inset: 50% auto auto 50%;
  transform: translate(-50%, -50%);
  margin: 0;
  padding: 0.375rem 0.625rem;
  border: 1px solid var(--penelopa-border);
  border-radius: 4px;
  background: var(--penelopa-surface);
  color: var(--penelopa-text-muted);
  font-size: 0.71875rem;
  pointer-events: none;
}

.penelopa-simulation-badge {
  margin-inline-start: auto;
  color: var(--penelopa-accent);
  font-size: 0.4375rem;
  line-height: 1;
}

/* Astrea's generic last-span fill rule also matches the badge; this more
   specific selector keeps the dot compact and right-aligned. */
.penelopa-tree-view .tree-node-text > .penelopa-simulation-badge {
  flex: 0 0 auto;
  margin-inline-start: auto;
}

/* ---- 4. Atlas splitter collapse affordances ---- */

/* Atlas 0.3.0 hides a collapsed split together with its expand chevron. Keep
   the chevron reachable so a required region can always be restored even
   though the simulation page deliberately hides Atlas' toolbars. */
.penelopa-simulation .atlas-v2-splitter {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.25rem;
}

.penelopa-simulation .atlas-v2-splitter-collapse {
  z-index: 1;
  min-width: 1rem;
  min-height: 1rem;
  margin: 0;
  padding: 0;
  border: 1px solid var(--penelopa-border);
  border-radius: 4px;
  background: var(--penelopa-surface);
  color: var(--penelopa-text-muted);
  font-size: 0.6875rem;
  line-height: 1;
}

.penelopa-simulation .atlas-v2-splitter-collapse:hover {
  border-color: var(--penelopa-accent);
  background: var(--penelopa-selection);
  color: var(--penelopa-accent-strong);
}

.penelopa-simulation .atlas-v2-splitter[data-atlas-splitter-hidden="true"] {
  visibility: visible;
  opacity: 1;
  background: transparent;
}

.penelopa-simulation .atlas-v2-split-inline > .atlas-v2-splitter[data-atlas-splitter-hidden="true"] > [data-atlas-collapse-child="first"] {
  transform: translateX(0.5rem);
}

.penelopa-simulation .atlas-v2-split-inline > .atlas-v2-splitter[data-atlas-splitter-hidden="true"] > [data-atlas-collapse-child="second"] {
  transform: translateX(-0.5rem);
}

.penelopa-simulation .atlas-v2-split-block > .atlas-v2-splitter[data-atlas-splitter-hidden="true"] > [data-atlas-collapse-child="second"] {
  transform: translateY(-0.5rem);
}

/* ---- 5. Inspector ---- */

.penelopa-simulation-inspector {
  padding: 0.75rem;
}

.penelopa-simulation-property-list {
  margin: 0;
  padding: 0;
  list-style: none;
  border-top: 1px solid var(--penelopa-divider);
}

.penelopa-simulation-property {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  min-height: 1.75rem;
  border-bottom: 1px solid var(--penelopa-divider);
}

.penelopa-simulation-property.selected {
  background: var(--penelopa-selection);
  box-shadow: inset 2px 0 0 var(--penelopa-accent);
}

.penelopa-simulation-property-button {
  display: flex;
  flex: 1 1 auto;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem;
  min-width: 0;
  padding: 0.25rem 0.375rem;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: start;
  cursor: pointer;
}

.penelopa-simulation-property-button:hover:not(:disabled) {
  color: var(--penelopa-accent-strong);
}

.penelopa-simulation-property-button:disabled {
  color: var(--penelopa-text-muted);
  cursor: default;
}

.penelopa-simulation-property-button:focus-visible {
  outline: 2px solid var(--penelopa-focus);
  outline-offset: -2px;
}

.penelopa-simulation-property-name {
  overflow: hidden;
  font-family: var(--penelopa-font-mono);
  font-size: 0.71875rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.penelopa-simulation-property.selected .penelopa-simulation-property-name {
  color: var(--penelopa-accent-strong);
  font-weight: 600;
}

.penelopa-simulation-current {
  color: var(--penelopa-text-muted);
  font-family: var(--penelopa-font-mono);
  font-size: 0.6875rem;
  font-variant-numeric: tabular-nums;
}

.penelopa-simulation-property-meta {
  flex: 0 0 auto;
  padding-inline-end: 0.375rem;
  color: var(--penelopa-text-muted);
  font-size: 0.625rem;
  white-space: nowrap;
}

.penelopa-simulation-track-editor {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-top: 0.5rem;
  padding-top: 0.625rem;
  border-top: 1px solid var(--penelopa-divider);
}

.penelopa-simulation-track-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.penelopa-simulation-track-actions {
  display: flex;
  gap: 0.25rem;
  flex-wrap: wrap;
}

.penelopa-simulation-subtitle {
  margin: 0;
  color: var(--penelopa-text);
  font-family: var(--penelopa-font-mono);
  font-size: 0.71875rem;
  font-weight: 600;
}

.penelopa-simulation-keyframe-table {
  width: 100%;
  margin: 0;
  border-collapse: collapse;
  font-size: 0.6875rem;
}

.penelopa-simulation-keyframe-table th,
.penelopa-simulation-keyframe-table td {
  padding: 0.25rem 0.3125rem;
  border-bottom: 1px solid var(--penelopa-divider);
  text-align: start;
  vertical-align: middle;
}

.penelopa-simulation-keyframe-table th {
  color: var(--penelopa-text-muted);
  font-size: 0.59375rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  white-space: nowrap;
}

.penelopa-simulation-keyframe-table tbody tr:hover {
  background: var(--penelopa-hover);
}

.penelopa-simulation-keyframe-table tr.selected {
  background: var(--penelopa-selection);
  box-shadow: inset 2px 0 0 var(--penelopa-accent);
}

.penelopa-simulation-keyframe-table tr.selected:hover {
  background: var(--penelopa-selection);
}

.penelopa-simulation-keyframe-select {
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--penelopa-accent);
  font: inherit;
  font-family: var(--penelopa-font-mono);
  font-variant-numeric: tabular-nums;
  text-decoration: none;
  cursor: pointer;
}

.penelopa-simulation-keyframe-select:hover {
  text-decoration: underline;
}

.penelopa-simulation-keyframe-actions {
  display: flex;
  gap: 0.25rem;
  white-space: nowrap;
}

.penelopa-simulation-keyframe-actions .penelopa-action {
  height: 1.25rem;
  padding-inline: 0.3125rem;
  font-size: 0.625rem;
}

.penelopa-simulation-keyframe-editor {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-top: 0.25rem;
  padding: 0.625rem;
  border: 1px solid var(--penelopa-divider);
  border-radius: 4px;
  background: var(--penelopa-sunken);
}

.penelopa-simulation-field {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  margin: 0;
}

.penelopa-simulation-field label,
.penelopa-simulation-bezier-grid label {
  color: var(--penelopa-text-muted);
  font-size: 0.59375rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.penelopa-simulation-input {
  width: 100%;
  height: 1.5rem;
  box-sizing: border-box;
  border: 1px solid var(--penelopa-border);
  border-radius: 4px;
  padding: 0 0.375rem;
  background: var(--penelopa-surface);
  color: var(--penelopa-text);
  font-family: var(--penelopa-font-mono);
  font-size: 0.6875rem;
  font-variant-numeric: tabular-nums;
}

.penelopa-simulation-input:focus-visible {
  outline: 2px solid var(--penelopa-focus);
  outline-offset: 0;
}

.penelopa-simulation-input[type="number"] {
  appearance: textfield;
  -moz-appearance: textfield;
}

.penelopa-simulation-input[type="number"]::-webkit-outer-spin-button,
.penelopa-simulation-input[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.penelopa-simulation-input:disabled {
  color: var(--penelopa-text-disabled);
}

.penelopa-simulation-bezier-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.375rem;
}

.penelopa-simulation-bezier-grid label {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.penelopa-simulation-inline-error {
  margin: 0;
  color: var(--penelopa-danger-text);
  font-size: 0.6875rem;
  line-height: 1.4;
}

/* ---- 6. Timeline ---- */

.penelopa-simulation-timeline {
  width: 100%;
  height: 100%;
  min-height: 0;
  box-sizing: border-box;
  overflow: auto;
  background: var(--penelopa-surface);
}

.penelopa-simulation-timeline-content {
  padding: 0.5rem 0.75rem 0.75rem;
}

.penelopa-simulation-section-title {
  margin: 0;
  color: var(--penelopa-text-muted);
  font-size: 0.625rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.penelopa-simulation-timeline-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  min-height: 1.5rem;
}

.penelopa-simulation-zoom {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.penelopa-simulation-zoom .penelopa-action {
  width: 1.375rem;
  padding: 0;
  font-size: 0.75rem;
}

.penelopa-simulation-zoom-value {
  min-width: 2rem;
  color: var(--penelopa-text-secondary);
  font-family: var(--penelopa-font-mono);
  font-size: 0.6875rem;
  font-variant-numeric: tabular-nums;
  text-align: center;
}

.penelopa-simulation-timeline-grid {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  margin-top: 0.375rem;
}

.penelopa-simulation-timeline-labels {
  flex: 0 0 5.5rem;
  min-width: 0;
  border-top: 1px solid var(--penelopa-divider);
  user-select: none;
}

.penelopa-simulation-label-spacer {
  display: flex;
  align-items: center;
  height: 1.75rem;
  padding-inline-start: 0.25rem;
  color: var(--penelopa-text-muted);
  font-size: 0.59375rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.penelopa-simulation-track-label {
  display: flex;
  align-items: center;
  height: 1.75rem;
  padding: 0 0.375rem;
  overflow: hidden;
  border-top: 1px solid var(--penelopa-divider);
  color: var(--penelopa-text-secondary);
  font-family: var(--penelopa-font-mono);
  font-size: 0.6875rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.penelopa-simulation-track-label.selected {
  background: var(--penelopa-selection);
  box-shadow: inset 2px 0 0 var(--penelopa-accent);
  color: var(--penelopa-accent-strong);
  font-weight: 600;
}

.penelopa-simulation-timeline-scroll {
  flex: 1 1 auto;
  min-width: 0;
  overflow-x: auto;
}

.penelopa-simulation-timeline-content-inner {
  position: relative;
}

.penelopa-simulation-ruler {
  position: relative;
  height: 1.75rem;
  box-sizing: border-box;
  border-top: 1px solid var(--penelopa-divider);
  border-bottom: 1px solid var(--penelopa-divider);
  background: var(--penelopa-sunken);
}

.penelopa-simulation-tick {
  position: absolute;
  top: 0.3125rem;
  z-index: 2;
  transform: translateX(-50%);
  color: var(--penelopa-text-muted);
  font-family: var(--penelopa-font-mono);
  font-size: 0.625rem;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
}

.penelopa-simulation-tick:hover {
  color: var(--penelopa-accent-strong);
}

/* The closing tick sits on the 100% edge; keep its label inside the ruler. */
.penelopa-simulation-tick:last-of-type {
  transform: translateX(-100%);
}

.penelopa-simulation-scrubber {
  position: absolute;
  left: 0;
  bottom: 0;
  z-index: 1;
  width: 100%;
  height: 0.875rem;
  margin: 0;
  accent-color: var(--penelopa-accent);
  cursor: ew-resize;
  opacity: 0.85;
}

.penelopa-simulation-lane {
  position: relative;
  height: 1.75rem;
  box-sizing: border-box;
  border-bottom: 1px solid var(--penelopa-divider);
}

.penelopa-simulation-lane:hover {
  background: color-mix(in srgb, var(--penelopa-hover) 60%, transparent);
}

.penelopa-simulation-keyframe {
  position: absolute;
  top: 50%;
  width: 0.5rem;
  height: 0.5rem;
  padding: 0;
  transform: translate(-50%, -50%) rotate(45deg);
  border: 1px solid var(--penelopa-accent);
  border-radius: 1px;
  background: var(--penelopa-surface);
  cursor: grab;
  touch-action: none;
  user-select: none;
}

.penelopa-simulation-keyframe:hover {
  background: var(--penelopa-selection);
}

.penelopa-simulation-keyframe.selected {
  background: var(--penelopa-accent);
  border-color: var(--penelopa-accent);
}

.penelopa-simulation-keyframe::before {
  content: "";
  position: absolute;
  inset: -0.35rem;
}

.penelopa-simulation-keyframe:focus-visible {
  outline: 2px solid var(--penelopa-focus);
  outline-offset: 2px;
}

.penelopa-simulation-playhead {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 1px;
  background: var(--penelopa-accent);
  pointer-events: none;
}

.penelopa-simulation-playhead::before {
  content: "";
  position: absolute;
  top: 0;
  left: -0.25rem;
  border-right: 0.25rem solid transparent;
  border-left: 0.25rem solid transparent;
  border-top: 0.35rem solid var(--penelopa-accent);
}

/* ---- 7. Narrow-viewport chrome ---- */

@media (max-width: 900px) {
  .penelopa-simulation-topbar {
    flex-wrap: wrap;
    gap: 0.375rem;
    padding-block: 0.375rem;
  }

  .penelopa-simulation-transport {
    margin-inline-start: 0;
    width: 100%;
  }

  .penelopa-simulation-status {
    min-width: 3.5rem;
  }
}

/* Atlas 0.4.0 renders a tool-header close/collapse control for every tool.
   Simulation regions are protected: they can be collapsed via splitters but
   must not expose a close affordance (SRS 4.2.2, ED-... / SIM-...). */
.penelopa-simulation .atlas-v2-panel-close {
  display: none;
}

@media (prefers-reduced-motion: reduce) {
  .penelopa-simulation *,
  .penelopa-simulation *::before,
  .penelopa-simulation *::after {
    transition-duration: 0s !important;
    animation-duration: 0s !important;
  }
}

.penelopa-simulation-document {
  max-width: 11rem;
  height: 1.75rem;
  padding: 0 0.375rem;
  border: 1px solid var(--atlas-border, var(--penelopa-border));
  border-radius: 4px;
  background: var(--penelopa-surface);
  color: var(--penelopa-text);
  font-size: 0.75rem;
}
