:root {
  --bg-deep: #0F1318;
  --bg-panel: #161B22;
  --border-panel: #2A3441;
  --border-panel-secondary: #3A4A5C;
  --grid-line: #1E2530;
  --text-muted: #6B7B8D;
  --text-primary: #C8D1DB;
  --text-bright: #E8EDF2;
  --accent-active: #6EC4E8;
  --accent-success: #7EDBA0;
  --accent-warning: #F0C674;
  --accent-error: #E85D75;
  --accent-idle: #4A5568;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html, body {
  width: 100%;
  height: 100%;
  font-family: 'IBM Plex Mono', monospace;
  background-color: var(--bg-deep);
  color: var(--text-primary);
  font-size: 16px;
  line-height: 1.5;
}

body {
  overflow-x: hidden;
}

/* ========== DASHBOARD SECTION ========== */

#dashboard {
  width: 100vw;
  height: 100dvh;
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  grid-template-rows: repeat(8, 1fr);
  gap: 4px;
  padding: 16px;
  background-color: var(--bg-deep);
  overflow: hidden;
}

.panel {
  background-color: var(--bg-panel);
  border: 1px solid var(--border-panel);
  border-radius: 2px;
  padding: 12px;
  position: relative;
  display: flex;
  flex-direction: column;
}

.panel-label {
  display: block;
  font-family: 'Space Grotesk', sans-serif;
  font-size: 0.6875rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 8px;
  font-weight: 500;
}

.domain-label {
  position: absolute;
  top: 12px;
  left: 12px;
  font-size: 0.625rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--text-muted);
  z-index: 10;
}

/* Blur-focus animation */
.blur-focus-enter {
  filter: blur(12px);
  opacity: 0;
  transition: filter 800ms cubic-bezier(0.25, 0.46, 0.45, 0.94),
              opacity 800ms cubic-bezier(0.25, 0.46, 0.45, 0.94);
  animation: stagger-in 800ms cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
}

@keyframes stagger-in {
  from {
    filter: blur(12px);
    opacity: 0;
  }
  to {
    filter: blur(0px);
    opacity: 1;
  }
}

.blur-focus-enter[style*="--stagger:0"] {
  animation-delay: 0ms;
}
.blur-focus-enter[style*="--stagger:1"] {
  animation-delay: 150ms;
}
.blur-focus-enter[style*="--stagger:2"] {
  animation-delay: 300ms;
}
.blur-focus-enter[style*="--stagger:3"] {
  animation-delay: 450ms;
}
.blur-focus-enter[style*="--stagger:4"] {
  animation-delay: 600ms;
}
.blur-focus-enter[style*="--stagger:5"] {
  animation-delay: 750ms;
}
.blur-focus-enter[style*="--stagger:6"] {
  animation-delay: 900ms;
}

/* Primary Panel */
.panel-primary {
  grid-column: 1 / 9;
  grid-row: 1 / 6;
  display: flex;
  flex-direction: column;
  padding-top: 32px;
}

#swimlane-svg {
  flex: 1;
  margin-top: 12px;
  min-height: 200px;
}

/* SVG grid styling */
.grid-line-primary {
  stroke: var(--border-panel);
  stroke-width: 1;
}

.grid-line-dotted {
  stroke: var(--grid-line);
  stroke-width: 1;
  stroke-dasharray: 2 4;
}

/* Swimlane bars */
.swim-bar {
  opacity: 0.9;
  rx: 1;
}

.swim-active {
  fill: var(--accent-active);
}

.swim-success {
  fill: var(--accent-success);
}

.swim-warning {
  fill: var(--accent-warning);
}

.swim-error {
  fill: var(--accent-error);
}

/* Animate swimlane bars */
@keyframes bar-expand {
  from {
    opacity: 0;
  }
  to {
    opacity: 0.9;
  }
}

.swim-bar {
  animation: bar-expand 800ms cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
}

/* Metric Panels */
.panel-metric {
  grid-column: 9 / 13;
  grid-row: auto;
  border-left: 2px solid var(--accent-active);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.panel-metric-1 {
  grid-row: 1 / 3;
}

.panel-metric-2 {
  grid-row: 3 / 5;
}

.panel-metric-3 {
  grid-row: 5 / 7;
}

.metric-value {
  font-size: clamp(1.5rem, 4vw, 2.5rem);
  font-weight: 600;
  color: var(--text-bright);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
  line-height: 1.1;
}

.sparkline {
  height: 30px;
  margin-top: 8px;
  opacity: 0.8;
}

/* Log Panel */
.panel-log {
  grid-column: 9 / 13;
  grid-row: 6 / 9;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

#log-feed {
  flex: 1;
  overflow-y: auto;
  font-size: 0.75rem;
  line-height: 1.6;
  font-variant-numeric: tabular-nums;
}

.log-entry {
  color: var(--text-primary);
  opacity: 0;
  animation: log-fade-in 400ms cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding: 2px 0;
}

@keyframes log-fade-in {
  from {
    filter: blur(4px);
    opacity: 0;
  }
  to {
    filter: blur(0px);
    opacity: 1;
  }
}

.log-entry:nth-child(1) { animation-delay: 0ms; }
.log-entry:nth-child(2) { animation-delay: 100ms; }
.log-entry:nth-child(3) { animation-delay: 200ms; }
.log-entry:nth-child(4) { animation-delay: 300ms; }
.log-entry:nth-child(5) { animation-delay: 400ms; }
.log-entry:nth-child(6) { animation-delay: 500ms; }
.log-entry:nth-child(7) { animation-delay: 600ms; }
.log-entry:nth-child(8) { animation-delay: 700ms; }

.log-ts {
  color: var(--text-muted);
  margin-right: 8px;
  font-variant-numeric: tabular-nums;
}

.log-lvl {
  display: inline-block;
  width: 20px;
  margin-right: 6px;
  font-weight: 600;
}

.log-info {
  color: var(--accent-active);
}

.log-warn {
  color: var(--accent-warning);
}

.log-err {
  color: var(--accent-error);
}

/* Timeline Panel */
.panel-timeline {
  grid-column: 1 / 9;
  grid-row: 6 / 9;
  display: flex;
  flex-direction: column;
}

#timeline-track {
  flex: 1;
  overflow-x: auto;
  overflow-y: hidden;
}

#timeline-svg {
  min-width: 100%;
  height: 100%;
}

.event-marker {
  opacity: 0.8;
}

.marker-active {
  fill: var(--accent-active);
}

.marker-success {
  fill: var(--accent-success);
}

.marker-warning {
  fill: var(--accent-warning);
}

.marker-error {
  fill: var(--accent-error);
}

.timeline-label {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 0.65rem;
  fill: var(--text-muted);
  text-anchor: middle;
  font-weight: 500;
}

/* Status Grid Panel */
.panel-status {
  grid-column: 1 / 9;
  grid-row: 7 / 9;
  display: flex;
  flex-direction: column;
}

#status-grid {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(16, 1fr);
  grid-template-rows: repeat(12, 1fr);
  gap: 2px;
  margin-top: 8px;
}

.status-indicator {
  width: 8px;
  height: 8px;
  border-radius: 1px;
  opacity: 0.8;
}

.status-active {
  background-color: var(--accent-active);
}

.status-success {
  background-color: var(--accent-success);
}

.status-warning {
  background-color: var(--accent-warning);
}

.status-error {
  background-color: var(--accent-error);
}

.status-idle {
  background-color: var(--accent-idle);
}

@keyframes pulse {
  0%, 100% { opacity: 0.6; }
  50% { opacity: 1; }
}

.status-indicator {
  animation: pulse 2s ease-in-out infinite;
}

.status-indicator:nth-child(1) { animation-delay: 0ms; }
.status-indicator:nth-child(2) { animation-delay: 100ms; }
.status-indicator:nth-child(3) { animation-delay: 200ms; }
.status-indicator:nth-child(4) { animation-delay: 300ms; }
.status-indicator:nth-child(5) { animation-delay: 400ms; }
.status-indicator:nth-child(6) { animation-delay: 500ms; }
.status-indicator:nth-child(7) { animation-delay: 600ms; }
.status-indicator:nth-child(8) { animation-delay: 700ms; }

/* ========== FULL-WIDTH SECTIONS ========== */

.full-section {
  width: 100vw;
  min-height: 100vh;
  padding: 60px 40px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  position: relative;
  overflow: hidden;
}

.section-label {
  position: absolute;
  top: 40px;
  left: 40px;
  font-family: 'Space Grotesk', sans-serif;
  font-size: 0.75rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-muted);
  font-weight: 500;
  z-index: 5;
}

/* Section 2: Architecture */
#section-architecture {
  background-color: var(--bg-deep);
}

.arch-diagram {
  width: 90%;
  max-width: 1000px;
  height: auto;
  aspect-ratio: 1000 / 600;
}

.arch-node {
  fill: var(--bg-panel);
  stroke: var(--border-panel);
  stroke-width: 1;
}

.arch-node-label {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 0.75rem;
  fill: var(--text-primary);
  text-anchor: middle;
  font-weight: 500;
}

.arch-edge {
  stroke: var(--accent-active);
  stroke-width: 1;
  opacity: 0.5;
}

/* Section 3: Throughput */
#section-throughput {
  background-color: var(--bg-deep);
}

.throughput-chart {
  width: 90%;
  max-width: 1200px;
  height: auto;
  aspect-ratio: 1200 / 500;
}

.area-fill-blue {
  fill: var(--accent-active);
  opacity: 0.2;
}

.area-fill-gray {
  fill: var(--accent-idle);
  opacity: 0.1;
}

.throughput-line {
  stroke: var(--accent-active);
  stroke-width: 2;
  opacity: 0.8;
}

.axis-label {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 0.65rem;
  fill: var(--text-muted);
  font-weight: 500;
}

.throughput-label {
  font-variant-numeric: tabular-nums;
}

/* Section 4: Signal */
#section-signal {
  background-color: var(--bg-deep);
  min-height: 60vh;
  display: flex;
  justify-content: center;
  align-items: center;
}

.signal-section {
  padding: 0;
}

.signal-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  text-align: center;
  filter: blur(8px);
  opacity: 0;
  animation: signal-fade-in 800ms cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
  animation-delay: 1500ms;
}

@keyframes signal-fade-in {
  from {
    filter: blur(8px);
    opacity: 0;
  }
  to {
    filter: blur(0px);
    opacity: 1;
  }
}

.signal-domain {
  display: block;
  font-size: clamp(1.25rem, 3vw, 2rem);
  font-weight: 600;
  color: var(--text-bright);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.signal-version {
  display: block;
  font-size: 0.875rem;
  color: var(--text-muted);
  font-weight: 400;
}

.signal-timestamp {
  display: block;
  font-size: 0.75rem;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  font-weight: 400;
}

/* ========== SCROLL BEHAVIOR ========== */

html {
  scroll-behavior: smooth;
}

/* Lock initial scroll until dashboard animation completes */
body.scroll-locked {
  overflow: hidden;
}

/* ========== INTERSECTION OBSERVER BLUR-FOCUS ========== */

.blur-focus-scroll {
  filter: blur(8px);
  opacity: 0.3;
  transition: filter 300ms cubic-bezier(0.25, 0.46, 0.45, 0.94),
              opacity 300ms cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.blur-focus-scroll.in-view {
  filter: blur(0px);
  opacity: 1;
}

/* ========== SCROLLBAR STYLING ========== */

::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: var(--bg-deep);
}

::-webkit-scrollbar-thumb {
  background: var(--text-muted);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-primary);
}

/* ========== RESPONSIVE DESIGN ========== */

@media (max-width: 1024px) {
  #dashboard {
    grid-template-columns: 1fr;
    grid-template-rows: auto;
    gap: 8px;
    height: auto;
    min-height: 100dvh;
  }

  .panel-primary {
    grid-column: 1;
    grid-row: auto;
    min-height: 40vh;
  }

  .panel-metric {
    grid-column: 1;
    grid-row: auto;
    min-height: 15vh;
  }

  .panel-metric-1,
  .panel-metric-2,
  .panel-metric-3 {
    grid-row: auto;
  }

  .panel-log {
    grid-column: 1;
    grid-row: auto;
    min-height: 25vh;
  }

  .panel-timeline {
    grid-column: 1;
    grid-row: auto;
    min-height: 20vh;
  }

  .panel-status {
    grid-column: 1;
    grid-row: auto;
    min-height: 20vh;
  }
}

@media (max-width: 640px) {
  #dashboard {
    padding: 12px;
    gap: 6px;
  }

  .panel {
    padding: 10px;
    border-radius: 1px;
  }

  .domain-label {
    font-size: 0.55rem;
  }

  .panel-label {
    font-size: 0.6rem;
    margin-bottom: 6px;
  }

  .metric-value {
    font-size: 1.5rem;
  }

  .full-section {
    padding: 40px 20px;
  }

  .section-label {
    font-size: 0.65rem;
    top: 20px;
    left: 20px;
  }

  .arch-diagram,
  .throughput-chart {
    width: 95%;
  }
}
