/**
 * Section 2: Problem - Structural Ceiling
 * Building visualization and metrics
 */

.section-problem {
  background-color: var(--bg-secondary);
}

.section-problem .section-content {
  max-width: var(--container-max);
  margin: 0 auto;
  width: 100%;
}

.section-problem .problem-visual {
  margin-bottom: var(--space-8);
}

/* Ceiling Demo Container */
.ceiling-demo {
  position: relative;
  display: grid;
  grid-template-columns: 1fr 300px;
  gap: var(--space-6);
  height: 500px;
  padding: var(--space-6);
  background-color: var(--bg-tertiary);
  border-radius: var(--radius-lg);
  border: 1px solid rgba(255, 255, 255, 0.05);
  overflow: hidden;
}

/* Building Stack Visualization - scrollable container */
.building-stack {
  position: relative;
  height: 100%;
  overflow-y: auto;
  overflow-x: hidden;
  padding-bottom: var(--space-4);
  padding-top: var(--space-16);
}

/* Custom scrollbar */
.building-stack::-webkit-scrollbar {
  width: 6px;
}

.building-stack::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.05);
  border-radius: 3px;
}

.building-stack::-webkit-scrollbar-thumb {
  background: var(--accent-orange);
  border-radius: 3px;
}

.building-stack::-webkit-scrollbar-thumb:hover {
  background: var(--accent-green);
}

/* Inner wrapper for tower alignment */
.building-stack-inner {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: center;
  min-height: 100%;
}

/* Antenna on top of tower */
.building-antenna {
  width: 4px;
  height: 120px;
  background: linear-gradient(180deg, 
    var(--accent-orange) 0%,
    var(--text-secondary) 30%,
    var(--text-muted) 100%
  );
  border-radius: 2px 2px 0 0;
  position: relative;
  margin-bottom: -2px;
}

.building-antenna::before {
  content: '';
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 8px;
  height: 8px;
  background: var(--accent-orange);
  border-radius: 50%;
  box-shadow: 0 0 10px var(--accent-orange);
}

.building-antenna::after {
  content: '';
  position: absolute;
  top: 15px;
  left: 50%;
  transform: translateX(-50%);
  width: 20px;
  height: 2px;
  background: var(--text-muted);
  border-radius: 1px;
}

.building-tower {
  position: relative;
  width: 60px;
  display: flex;
  flex-direction: column-reverse;
  transition: width 0.3s ease;
}

.building-tower.wide {
  width: 100px;
}

.building-floor {
  width: 100%;
  height: 8px;
  margin-bottom: 1px;
  background: linear-gradient(90deg, 
    rgba(100, 100, 100, 0.8) 0%, 
    rgba(150, 150, 150, 0.9) 50%, 
    rgba(100, 100, 100, 0.8) 100%
  );
  border-radius: 1px;
  position: relative;
  transform-origin: bottom center;
  transition: background 0.2s ease, transform 0.2s ease;
}

.building-floor.stress-low {
  background: linear-gradient(90deg, 
    rgba(100, 150, 100, 0.8) 0%, 
    rgba(130, 180, 130, 0.9) 50%, 
    rgba(100, 150, 100, 0.8) 100%
  );
}

.building-floor.stress-medium {
  background: linear-gradient(90deg, 
    rgba(180, 150, 50, 0.8) 0%, 
    rgba(220, 180, 60, 0.9) 50%, 
    rgba(180, 150, 50, 0.8) 100%
  );
}

.building-floor.stress-high {
  background: linear-gradient(90deg, 
    rgba(200, 80, 60, 0.8) 0%, 
    rgba(255, 100, 80, 0.9) 50%, 
    rgba(200, 80, 60, 0.8) 100%
  );
}

.building-floor.stress-critical {
  background: linear-gradient(90deg, 
    rgba(255, 50, 50, 0.9) 0%, 
    rgba(255, 80, 80, 1) 50%, 
    rgba(255, 50, 50, 0.9) 100%
  );
  animation: pulse-stress 0.5s ease-in-out infinite alternate;
}

@keyframes pulse-stress {
  from { opacity: 0.8; }
  to { opacity: 1; }
}

.building-foundation {
  width: 120%;
  height: 12px;
  background: linear-gradient(180deg, #444 0%, #222 100%);
  border-radius: 2px;
  margin-top: 2px;
  transition: width 0.3s ease, background 0.3s ease;
}

.building-foundation.massive {
  width: 200%;
  background: linear-gradient(180deg, 
    var(--danger) 0%, 
    #441111 100%
  );
}

.ground-line {
  position: absolute;
  bottom: var(--space-4);
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, 
    transparent 0%, 
    #8B4513 20%, 
    #8B4513 80%, 
    transparent 100%
  );
}

/* Height Markers - positioned inside building-stack-inner */
.height-markers {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 14px; /* Align with foundation top */
  pointer-events: none;
  z-index: 10;
}

.height-marker {
  position: absolute;
  left: var(--space-2);
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--space-1);
  font-family: var(--font-data);
  font-size: var(--text-base);
  color: var(--text-primary);
  white-space: nowrap;
  transform: translateY(50%);
}

.height-marker::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 20px;
  height: 2px;
  background-color: var(--text-muted);
  transform: translateY(-4px);
}

.height-marker.stratum::before {
  background-color: var(--text-muted);
  width: 40px;
}

.marker-label {
  font-size: var(--text-sm);
  color: var(--text-primary);
  font-family: var(--font-narrative);
}

.marker-method {
  font-size: var(--text-sm);
  color: var(--text-primary);
  font-family: var(--font-data);
  font-style: italic;
}

.height-marker.stratum .marker-method {
  color: var(--muted-green);
  opacity: 1;
}

.marker-cost {
  font-size: var(--text-sm);
  color: var(--text-primary);
  font-family: var(--font-data);
}

/* Metrics Panel */
.ceiling-metrics {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  padding: var(--space-4);
  background-color: rgba(0, 0, 0, 0.3);
  border-radius: var(--radius-md);
  border: 1px solid rgba(255, 255, 255, 0.05);
  align-self: start;
}

.metric-row {
  display: grid;
  grid-template-columns: 24px 1fr;
  grid-template-rows: auto auto;
  gap: var(--space-2) var(--space-3);
  align-items: center;
}

.metric-icon {
  grid-row: span 2;
  font-size: var(--text-lg);
  opacity: 0.6;
}

.metric-data {
  display: flex;
  align-items: baseline;
  gap: var(--space-1);
}

.metric-label {
  font-size: var(--text-xs);
  color: var(--text-secondary);
  margin-right: auto;
}

.metric-value {
  font-size: var(--text-xl);
  color: var(--text-primary);
  min-width: 60px;
  text-align: right;
  transition: color 0.3s ease;
}

.metric-value.warning {
  color: var(--warning);
}

.metric-value.danger {
  color: var(--danger);
}

.metric-unit {
  font-size: var(--text-sm);
  color: var(--text-secondary);
}

.metric-bar {
  grid-column: 2;
  height: 6px;
  background-color: rgba(255, 255, 255, 0.05);
  border-radius: 3px;
  overflow: hidden;
}

.metric-bar-fill {
  height: 100%;
  width: 0%;
  background-color: var(--accent-green);
  border-radius: 3px;
  transition: width 0.1s linear, background-color 0.3s ease;
}

.metric-bar-fill.mass-bar {
  background-color: var(--accent-blue);
}

.metric-bar-fill.stress-bar {
  background-color: var(--accent-green);
}

.metric-bar-fill.stress-bar.warning {
  background-color: var(--warning);
}

.metric-bar-fill.stress-bar.danger {
  background-color: var(--danger);
}

.metric-bar-fill.wind-bar {
  background-color: var(--accent-blue);
}

/* Stress Warning Overlay */
.stress-warning {
  position: absolute;
  bottom: 0;
  left: var(--space-8);
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-4);
  background-color: rgba(255, 50, 50, 0.9);
  color: var(--bg-primary);
  font-family: var(--font-data);
  font-weight: var(--weight-bold);
  border-radius: var(--radius-md);
  animation: warning-pulse 0.5s ease-in-out infinite alternate;
  z-index: 10;
  text-align: left;
}

.stress-warning .warning-icon {
  font-size: var(--text-lg);
}

.stress-warning .warning-text {
  font-size: var(--text-base);
  letter-spacing: 0.1em;
}

.stress-warning .warning-subtext {
  font-size: var(--text-xs);
  font-weight: var(--weight-normal);
  opacity: 0.9;
}

@keyframes warning-pulse {
  from { 
    box-shadow: 0 0 20px rgba(255, 50, 50, 0.5);
    transform: scale(1);
  }
  to { 
    box-shadow: 0 0 40px rgba(255, 50, 50, 0.8);
    transform: scale(1.02);
  }
}

.warning-icon {
  font-size: var(--text-2xl);
}

/* Problem content */
.problem-quote {
  font-size: var(--text-xl);
  text-align: center;
  margin-bottom: var(--space-6);
}

.problem-explanation {
  max-width: 700px;
  margin: 0 auto;
}

/* Scroll hint for mobile */
.scroll-hint {
  display: none;
}

@media (max-width: 767px) {
  .scroll-hint {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-3);
    color: var(--text-secondary);
    font-size: var(--text-sm);
    text-align: center;
    animation: pulse-hint 2s ease-in-out infinite;
  }
  
  .scroll-hint-icon {
    font-size: var(--text-2xl);
    animation: bounce-hint 1.5s ease-in-out infinite;
  }
  
  @keyframes pulse-hint {
    0%, 100% { opacity: 0.7; }
    50% { opacity: 1; }
  }
  
  @keyframes bounce-hint {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-6px); }
  }
}

/* Responsive */
@media (max-width: 767px) {
  .ceiling-demo {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto auto; /* Added row for scroll hint */
    height: auto;
    gap: var(--space-4);
    padding: var(--space-4);
    overflow: visible;
  }
  
  .building-stack {
    height: 400px;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    border-radius: var(--radius-md);
    position: relative;
    scroll-snap-type: y proximity; /* Light snap for guided exploration */
  }
  
  .building-stack::before {
    content: '';
    position: sticky;
    top: 0;
    left: 0;
    right: 0;
    height: 40px;
    background: linear-gradient(180deg, var(--bg-tertiary) 0%, transparent 100%);
    pointer-events: none;
    z-index: 5;
  }
  
  .building-stack::after {
    content: '';
    position: sticky;
    bottom: 0;
    left: 0;
    right: 0;
    height: 40px;
    background: linear-gradient(0deg, var(--bg-tertiary) 0%, transparent 100%);
    pointer-events: none;
    z-index: 5;
  }
  
  .building-tower {
    width: 50px;
  }
  
  .building-tower.wide {
    width: 70px;
  }
  
  .building-foundation {
    width: 100%;
  }
  
  .building-foundation.massive {
    width: 140%;
  }
  
  .height-markers {
    display: block;
    left: var(--space-2);
    right: auto;
  }
  
  .height-marker {
    left: 0;
    right: auto;
    align-items: flex-start;
    font-size: var(--text-xs);
  }
  
  .height-marker::before {
    left: 0;
    right: auto;
    width: 12px;
  }
  
  .height-marker.stratum::before {
    width: 24px;
  }
  
  .marker-label {
    font-size: 9px;
  }
  
  .marker-method {
    font-size: 8px;
  }
  
  .marker-cost {
    font-size: 8px;
  }
  
  .ceiling-metrics {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: var(--space-2);
    padding: var(--space-3);
  }
  
  .metric-row {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: var(--space-1);
  }
  
  .metric-icon {
    font-size: var(--text-base);
    grid-row: unset;
  }
  
  .metric-data {
    flex-direction: column;
    align-items: center;
    gap: 0;
  }
  
  .metric-label {
    font-size: 9px;
    margin-right: 0;
    order: -1;
  }
  
  .metric-value {
    font-size: var(--text-lg);
    min-width: unset;
    text-align: center;
  }
  
  .metric-unit {
    font-size: var(--text-xs);
  }
  
  .metric-bar {
    display: none; /* Hide bars on mobile for cleaner look */
  }
}
