/* avalanche.css: styling for the avalanche in a rocking box demo.
 * Fedora Core 1 window chrome with space grey MLS-MPM 3D viewport,
 * refined timeline dock, tabbed control & telemetry sidebar, and exact receipts. */

:root {
  --lead: #6cc3b5;   /* Leader A */
  --twin1: #e8894f;  /* Twin B */
  --twin2: #efe6d2;  /* Twin C */
  --space-grey: #0b1220;
  --grid-line: #3b4252;
  --font-mono: var(--mono, 'CaskaydiaCove Nerd Font Mono', 'CaskaydiaCove NF', monospace);
  --font-sans: var(--sans, 'Lexend Deca', -apple-system, BlinkMacSystemFont, sans-serif);
}

* {
  box-sizing: border-box;
}

body.demo-page {
  background-color: #ffffff;
  color: #000000;
  font-family: var(--font-sans);
}

body.demo-page main {
  max-width: none;
}

.crumbs {
  font-size: 13px;
  color: #555;
  margin: 0 0 12px;
}

.hero2 {
  display: flex;
  flex-wrap: wrap;
  gap: 24px;
  margin-bottom: 24px;
  align-items: flex-start;
}

.hero-text {
  flex: 1 1 480px;
}

.hero-text h1 {
  font-size: 28px;
  margin: 0 0 10px;
}

.hero-text .lede {
  font-size: 15px;
  line-height: 1.55;
  color: #222;
  margin: 0 0 14px;
}

.release-box {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.pair-buttons {
  display: flex;
  gap: 8px;
}

.pair-buttons a.button {
  white-space: nowrap;
}

.hero-code {
  flex: 1 1 360px;
  min-width: 300px;
}

/* FC1 Window Frame */
.ws-window {
  display: flex;
  flex-direction: column;
  height: clamp(560px, 80vh, 820px);
  min-height: 520px;
  border: 1px solid #7a7a7a;
  background: #d4d0c8;
  box-shadow: 2px 2px 4px rgba(0,0,0,0.25);
  margin-bottom: 30px;
  overflow: hidden;
}

.ws-window.ws-max {
  position: fixed;
  inset: 0;
  z-index: 10000;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  margin: 0;
  border-radius: 0;
  border: none;
  max-width: none;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

body.ws-maxed {
  overflow: hidden;
}

.ws-titlebar {
  flex: 0 0 26px;
  background: linear-gradient(#fafafa, #d2d2d2);
  border-bottom: 1px solid #7a7a7a;
  padding: 4px 8px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  font-weight: 700;
  color: #000;
  user-select: none;
}

.ws-titlebar .ws-title-text {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 700;
  color: #000;
}

.ws-titlebar button {
  background: #ece9d8;
  border: 1px solid #7a7a7a;
  box-shadow: inset 1px 1px 0 #fff, inset -1px -1px 0 #a0a0a0;
  width: 18px;
  height: 18px;
  padding: 0;
  line-height: 14px;
  font-size: 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.demo-container {
  display: flex;
  flex-direction: row;
  border-top: 1px solid #fff;
  flex: 1 1 0;
  min-height: 0;
  height: 100%;
  overflow: hidden;
}

.viewport-panel {
  flex: 1 1 65%;
  display: flex;
  flex-direction: column;
  background: #e0ded8;
  border-right: 1px solid #7a7a7a;
  min-width: 0;
  height: 100%;
  overflow: hidden;
}

.canvas-wrapper {
  position: relative;
  flex: 1 1 0;
  min-height: 240px;
  height: 100%;
  width: 100%;
  background: radial-gradient(circle at 50% 40%, #1e2638 0%, #0b1220 85%);
  border-bottom: 1px solid #7a7a7a;
  box-shadow: inset 1px 1px 0 #000;
  overflow: hidden;
}

#renderCanvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  cursor: grab;
}

#renderCanvas:active {
  cursor: grabbing;
}

/* Overlay Legends & Pills */
.overlay-legend {
  position: absolute;
  top: 10px;
  left: 10px;
  background: rgba(13, 18, 29, 0.85);
  border: 1px solid #334155;
  color: #e2e8f0;
  padding: 6px 10px;
  font-size: 11px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  pointer-events: none;
  backdrop-filter: blur(2px);
  z-index: 5;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
}

.legend-swatch {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.camera-controls-floating {
  position: absolute;
  top: 10px;
  right: 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  z-index: 5;
}

.btn-icon {
  width: 26px;
  height: 26px;
  background: rgba(13, 18, 29, 0.85);
  border: 1px solid #334155;
  color: #e2e8f0;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
}

.btn-icon:hover {
  background: #1e293b;
  color: #ffffff;
}

.btn-icon.btn-active {
  background: #1e293b;
  border-color: #5BCEFA;
  color: #5BCEFA;
}

/* Engine Status Bar */
.engine-status {
  position: absolute;
  inset: auto 12px 32px 12px;
  margin: 0;
  padding: 6px 10px;
  background: rgba(15, 23, 42, 0.9);
  color: #ffffff;
  font-size: 11.5px;
  border: 1px solid #475569;
  z-index: 4;
}

.engine-status:empty {
  display: none;
}

.engine-name {
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 8px;
  margin: 0;
  color: #94a3b8;
  font-size: 11px;
  pointer-events: none;
  z-index: 4;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.engine-name:empty {
  display: none;
}

.engine-name.engine-bad {
  color: #ff8a80;
  font-weight: 700;
}

/* Timeline Playback Dock */
.timeline-dock {
  flex: 0 0 auto;
  background: #ece9d8;
  padding: 6px 10px;
  border-top: 1px solid #fff;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.playback-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.btn {
  background: #ece9d8;
  border: 1px solid #7a7a7a;
  box-shadow: inset 1px 1px 0 #fff, inset -1px -1px 0 #a0a0a0;
  padding: 3px 8px;
  font-size: 12px;
  font-family: var(--font-sans);
  cursor: pointer;
  color: #000;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  user-select: none;
}

.btn:active, .btn-active {
  box-shadow: inset 1px 1px 0 #a0a0a0, inset -1px -1px 0 #fff;
  background: #d8d4c8;
}

.btn-primary {
  font-weight: 700;
}

.btn-sm {
  padding: 2px 7px;
  font-size: 11.5px;
  gap: 5px;
}

#playPauseBtn {
  width: 64px;
  min-width: 64px;
  padding: 2px 6px;
  white-space: nowrap;
}

#playIcon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 9px;
  height: 9px;
  flex: 0 0 9px;
  font-size: 12px;
  line-height: 1;
}

#playIcon.is-pause {
  font-size: 0;
  gap: 2px;
}

#playIcon.is-pause::before,
#playIcon.is-pause::after {
  content: "";
  display: block;
  width: 2.5px;
  height: 8.5px;
  background: currentColor;
}

.speed-select {
  background: #ece9d8;
  border: 1px solid #7a7a7a;
  box-shadow: inset 1px 1px 0 #fff, inset -1px -1px 0 #a0a0a0;
  padding: 2px 4px;
  font-size: 12px;
  font-family: var(--font-sans);
  color: #000;
  cursor: pointer;
}

.timeline-slider-wrap {
  width: 100%;
}

.timeline-slider {
  width: 100%;
  margin: 2px 0;
  cursor: pointer;
}

.timeline-scrubber-info {
  font-size: 11px;
  font-family: var(--font-mono);
  color: #333;
}

/* Sidebar Panel */
.sidebar-panel {
  flex: 0 0 350px;
  max-width: 420px;
  min-width: 290px;
  height: 100%;
  background: #ece9d8;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-sizing: border-box;
}

.tab-nav {
  flex: 0 0 auto;
  display: flex;
  background: #d4d0c8;
  border-bottom: 1px solid #7a7a7a;
  padding: 4px 6px 0 6px;
  gap: 2px;
}

.tab-btn {
  border: 1px solid #7a7a7a;
  border-bottom: none;
  background: linear-gradient(#f6f6f6, #dedede);
  padding: 4px 10px;
  font-size: 12px;
  font-family: var(--font-sans);
  cursor: pointer;
  text-transform: lowercase;
  color: #000;
}

.tab-btn.active {
  background: #ece9d8;
  font-weight: 700;
  position: relative;
  top: 1px;
}

.tab-btn:focus-visible {
  outline: 2px solid #b0521f;
  outline-offset: -1px;
}

.tab-content {
  flex: 1 1 0;
  min-height: 0;
  max-height: none;
  padding: 10px;
  overflow-y: auto;
  box-sizing: border-box;
  min-width: 0;
}

.tab-pane {
  display: none;
  min-width: 0;
  max-width: 100%;
  box-sizing: border-box;
}

.tab-pane.active {
  display: block;
}

.card-section {
  background: #f4f2e9;
  border: 1px solid #7a7a7a;
  box-shadow: inset 1px 1px 0 #fff;
  padding: 10px;
  margin-bottom: 10px;
  box-sizing: border-box;
  min-width: 0;
  max-width: 100%;
}

.card-title,
.ws-window h1,
.ws-window h2,
.ws-window h3,
.ws-window h4,
.home2 .ws-window h1,
.home2 .ws-window h2,
.home2 .ws-window h3,
.home2 .ws-window h4,
.home2 .ws-window .card-title {
  font-size: 12px !important;
  font-weight: 700 !important;
  line-height: 1.3 !important;
  margin: 0 0 6px 0 !important;
  padding: 0 !important;
  border: 0 !important;
  text-transform: lowercase !important;
  letter-spacing: normal !important;
  color: #000000 !important;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.ws-window h1::after,
.ws-window h2::after,
.ws-window h3::after,
.ws-window h4::after,
.ws-window .card-title::after,
.home2 .ws-window h1::after,
.home2 .ws-window h2::after,
.home2 .ws-window h3::after,
.home2 .ws-window h4::after,
.home2 .ws-window .card-title::after {
  display: none !important;
  content: none !important;
  width: 0 !important;
  height: 0 !important;
}

/* Consensus Tether Controls */
.consensus-card {
  border-left: 3px solid var(--lead);
}

.tether-control-box {
  margin: 6px 0;
}

.tether-extremes-row, .tether-sub-row {
  display: flex;
  justify-content: space-between;
  font-size: 10px;
  color: #555;
}

.consensus-slider {
  width: 100%;
  margin: 4px 0;
}

.tether-badge {
  font-family: var(--font-mono);
  font-size: 11px;
  padding: 1px 5px;
  background: #fff;
  border: 1px solid #7a7a7a;
}

.tether-extreme.extreme-chaos {
  color: #b00020;
}

.tether-extreme.extreme-order {
  color: #1d4e4a;
}

.tether-divergence-block {
  margin-top: 8px;
  padding-top: 6px;
  border-top: 1px solid #d4d0c8;
}

.sep-value {
  font-family: var(--font-mono);
  font-weight: 700;
}

.divergence-bar-wrap {
  width: 100%;
  height: 6px;
  background: #dedede;
  border: 1px solid #7a7a7a;
  overflow: hidden;
  margin: 4px 0;
}

.divergence-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #6cc3b5 0%, #e8894f 50%, #d32f2f 100%);
  transition: width 0.08s ease;
}

/* Preset Buttons */
.preset-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.preset-opt[aria-pressed="true"] {
  background: #1d4e4a;
  color: #ffffff;
  font-weight: 700;
  box-shadow: inset 1px 1px 0 #0d2826;
}

/* Segmented Controls */
.segmented-control {
  display: inline-flex;
  border: 1px solid #7a7a7a;
  background: #dedede;
  border-radius: 2px;
  padding: 1px;
  gap: 1px;
  width: 100%;
}

.segmented-option {
  flex: 1;
  padding: 4px 6px;
  font-size: 11px;
  font-family: var(--font-sans);
  color: #333333;
  cursor: pointer;
  border: none;
  background: transparent;
  text-align: center;
  border-radius: 1px;
  text-transform: lowercase;
}

.segmented-option:hover {
  background: #eaeaea;
}

.segmented-option[aria-pressed="true"], .segmented-option.active {
  background: #1d4e4a;
  color: #ffffff;
  font-weight: 700;
}

.reversal-status {
  font-size: 11px;
  color: #444;
  line-height: 1.4;
  margin: 6px 0 0;
}

.reversal-status:empty {
  display: none;
}

/* Theme Picker Swatches */
.theme-picker {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
}

.theme-swatch {
  appearance: none;
  display: flex;
  height: 24px;
  padding: 2px;
  margin: 0;
  border: 1px solid #7a7a7a;
  border-radius: 2px;
  background: #25282e;
  cursor: pointer;
}

.theme-swatch span {
  flex: 1;
  height: 100%;
}

.theme-swatch:hover {
  border-color: #000;
}

.theme-swatch[aria-pressed="true"] {
  outline: 2px solid #1d4e4a;
  outline-offset: 1px;
  border-color: #1d4e4a;
}

.theme-swatch:focus-visible {
  outline: 2px solid #b0521f;
  outline-offset: 1px;
}

/* View Options & Switches */
.control-toggle-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 4px 0;
}

.switch {
  position: relative;
  display: inline-block;
  width: 32px;
  height: 18px;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider-toggle {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background-color: #c4c4c4;
  border: 1px solid #7a7a7a;
  border-radius: 9px;
  transition: 0.2s;
}

.slider-toggle:before {
  position: absolute;
  content: "";
  height: 12px;
  width: 12px;
  left: 2px;
  bottom: 2px;
  background-color: #ffffff;
  border-radius: 50%;
  box-shadow: 0 1px 2px rgba(0,0,0,0.3);
  transition: 0.2s;
}

.switch input:checked + .slider-toggle {
  background-color: #1d4e4a;
}

.switch input:checked + .slider-toggle:before {
  transform: translateX(14px);
}

/* Telemetry Rows */
.telemetry-row {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  margin-bottom: 4px;
}

.telemetry-label {
  color: #444;
}

.telemetry-val {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  color: #000;
}

.telemetry-block {
  background: #f4f2e9;
  border: 1px solid #7a7a7a;
  padding: 4px 6px;
  margin-bottom: 4px;
}

.telemetry-block.full-width {
  width: 100%;
}

.telemetry-block .telemetry-label {
  font-size: 11px;
  color: #555;
  margin-bottom: 2px;
}

.telemetry-block .telemetry-value {
  font-family: var(--font-mono);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  color: #000;
  word-break: break-all;
}

/* Parity Verification Table */
.parity-table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--font-mono);
  font-size: 11px;
  background: #ffffff;
  border: 1px solid #7a7a7a;
  margin-bottom: 8px;
}

.parity-table th {
  background: #e8e8e8;
  border-bottom: 1px solid #7a7a7a;
  padding: 4px 6px;
  text-align: left;
  font-weight: 700;
  color: #222;
  font-size: 10.5px;
  text-transform: lowercase;
}

.parity-table td {
  padding: 4px 6px;
  border-bottom: 1px solid #e0e0e0;
  color: #000;
  font-size: 11px;
}

.parity-table td.receipt-live {
  color: #2e7d32;
  font-weight: 700;
}

.parity-table td.receipt-bad {
  color: #b00020;
  font-weight: 700;
}

.legend-swatch-sm {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 4px;
  vertical-align: middle;
}

/* Terminal Monospace Boxes */
.receipt-stdout {
  background: #2e3440;
  border: 1px solid #4c566a;
  box-shadow: inset 1px 1px 2px #000;
  padding: 8px 10px;
  font-family: var(--font-mono);
  font-size: 11px;
  line-height: 1.45;
  color: #d8dee9;
  white-space: pre-wrap;
  word-break: break-all;
  max-height: 180px;
  overflow-y: auto;
  margin: 6px 0 10px;
}

.receipt-engine {
  font-size: 11px;
  line-height: 1.45;
  color: #333;
  margin: 6px 0;
}

.rec-receipt-box {
  background: #2e3440;
  border: 1px solid #4c566a;
  box-shadow: inset 1px 1px 2px #000;
  padding: 8px 10px;
  font-family: var(--font-mono);
  font-size: 11px;
  line-height: 1.45;
  color: #d8dee9;
  white-space: pre-wrap;
  word-break: break-all;
  margin-top: 8px;
}

.rec-receipt-box a {
  color: #88c0d0;
  text-decoration: underline;
}

.receipt-verified-badge {
  display: inline-block;
  background: #2e7d32;
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 6px;
  margin-bottom: 6px;
}

.code-pre {
  background: #2e3440;
  border: 1px solid #4c566a;
  box-shadow: inset 1px 1px 2px #000;
  padding: 8px 10px;
  font-family: var(--font-mono);
  font-size: 11px;
  line-height: 1.4;
  color: #d8dee9;
  max-height: 480px;
  overflow-x: auto;
  overflow-y: auto;
  white-space: pre;
  box-sizing: border-box;
  max-width: 100%;
}

.code-pre code {
  display: block;
}

/* Responsive Rules */
@media (max-width: 860px) {
  .hero2 {
    flex-direction: column;
  }
  .hero-code {
    width: 100%;
    min-width: 0;
  }
  .ws-window:not(.ws-max) {
    display: block;
    flex: none;
    height: auto;
    min-height: 0;
    overflow: hidden;
  }
  .ws-window:not(.ws-max) .demo-container {
    display: block;
    flex: none;
    height: auto;
    overflow: visible;
  }
  .ws-window:not(.ws-max) .viewport-panel {
    display: block;
    flex: none;
    border-right: none;
    border-bottom: 1px solid #7a7a7a;
    width: 100%;
    min-width: 0;
    height: auto;
    overflow: visible;
  }
  .ws-window:not(.ws-max) .canvas-wrapper {
    display: block;
    flex: none;
    width: 100%;
    height: 340px;
    min-height: 280px;
  }
  .ws-window:not(.ws-max) .timeline-dock {
    flex: none;
    width: 100%;
    height: auto;
  }
  .ws-window:not(.ws-max) .sidebar-panel {
    display: block;
    flex: none;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    height: auto;
    overflow: visible;
  }
  .ws-window:not(.ws-max) .tab-content {
    display: block;
    flex: none;
    height: auto;
    max-height: none;
    overflow-y: visible;
  }
  .overlay-legend {
    flex-direction: row;
    gap: 8px;
    padding: 3px 7px;
    font-size: 10px;
    top: 6px;
    left: 6px;
  }
  .legend-item > span:not(.legend-swatch) {
    display: none;
  }
  .legend-item::after {
    content: attr(data-short);
    font-weight: 700;
  }
  #stepPrevBtn,
  #stepNextBtn {
    display: none;
  }
  .playback-controls {
    gap: 4px;
  }
  .timeline-dock {
    padding: 5px 8px;
    gap: 4px;
  }
  .ws-window.ws-max .demo-container {
    flex-direction: column;
    height: 100%;
    flex: 1 1 0;
    min-height: 0;
    overflow: hidden;
  }
  .ws-window.ws-max .viewport-panel {
    flex: 1 1 auto;
    min-height: 0;
    height: auto;
    width: 100%;
    border-right: none;
    border-bottom: 1px solid #7a7a7a;
    display: flex;
    flex-direction: column;
    overflow: hidden;
  }
  .ws-window.ws-max .canvas-wrapper {
    flex: 1 1 0;
    min-height: 180px;
    height: 100%;
    width: 100%;
  }
  .ws-window.ws-max .timeline-dock {
    flex: 0 0 auto;
    width: 100%;
  }
  .ws-window.ws-max .sidebar-panel {
    flex: 0 0 35dvh;
    height: 35dvh;
    max-height: 35dvh;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
  }
  .ws-window.ws-max .tab-content {
    flex: 1 1 0;
    min-height: 0;
    overflow-y: auto;
  }
  .hero-code pre.code {
    white-space: pre-wrap;
    word-break: break-all;
  }
}
