/**
 * Subway Progress CSS - UC-504.2 Report UX Improvements
 * Worker B1-B4: Visual styling for subway map progress indicator
 *
 * Features:
 * - Horizontal subway map layout
 * - Color-coded station states (pending/processing/completed/failed)
 * - Smooth animations and transitions
 * - Mobile responsive with horizontal scroll
 * - Accessible ARIA support
 */

/* Subway Progress Container */
.subway-progress-container {
  position: sticky;
  top: 0;
  left: 0;
  right: 0;
  background: linear-gradient(to bottom, #ffffff 0%, #f8fafc 100%);
  border-bottom: 1px solid #e2e8f0;
  padding: 12px 16px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
  z-index: 900;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  margin-bottom: 16px;
}

/* Hide scrollbar but allow scroll */
.subway-progress-container::-webkit-scrollbar {
  height: 0;
  display: none;
}

/* Progress Header */
.subway-progress-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  font-size: 13px;
  font-weight: 600;
  color: #475569;
  padding: 0 4px;
}

.progress-count {
  color: #64748b;
}

.progress-percentage {
  color: var(--green-grade, #71B956);
  font-size: 16px;
  font-weight: 700;
}

/* Estimated time display */
.subway-progress__time-estimate {
  font-size: 0.875rem;
  color: var(--text-secondary, #6b7280);
  font-weight: 500;
  font-style: italic;
}

/* 100% state */
.subway-progress-container[data-complete="true"] .progress-percentage {
  color: var(--green-grade, #71B956);
  animation: pulse-complete 2s ease-in-out;
}

@keyframes pulse-complete {
  0%, 100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.1);
  }
}

/* Subway Map Container */
.subway-progress-map {
  display: flex;
  align-items: flex-start;
  gap: 0;
  min-width: max-content;
  padding: 0 8px;
  position: relative;
}

/* Individual Station */
.subway-station {
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
  min-width: 60px;
  flex-shrink: 0;
  transition: transform 0.2s ease;
}

.subway-station:hover {
  transform: translateY(-2px);
}

/* Station Circle */
.station-circle {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  border: 3px solid;
  background: white;
  transition: all 0.3s ease;
  z-index: 2;
  position: relative;
}

/* Station States */

/* Pending (gray) */
.subway-station[data-status="pending"] .station-circle {
  border-color: #9ca3af;
  color: #9ca3af;
}

/* Processing (yellow) */
.subway-station[data-status="processing"] .station-circle {
  border-color: #f59e0b;
  color: #f59e0b;
  animation: pulse-station 1.5s ease-in-out infinite;
}

@keyframes pulse-station {
  0%, 100% {
    transform: scale(1);
    box-shadow: 0 0 0 0 rgba(245, 158, 11, 0.4);
  }
  50% {
    transform: scale(1.05);
    box-shadow: 0 0 0 8px rgba(245, 158, 11, 0);
  }
}

/* Completed (green) */
.subway-station[data-status="completed"] .station-circle {
  border-color: var(--green-grade, #71B956);
  color: white;
  background: var(--green-grade, #71B956);
}

/* Failed (red) */
.subway-station[data-status="failed"] .station-circle {
  border-color: var(--red-grade, #D63B3B);
  color: white;
  background: var(--red-grade, #D63B3B);
}

/* Connecting Lines */
.station-line {
  position: absolute;
  top: 16px;
  height: 3px;
  width: 28px;
  background: #e5e7eb;
  z-index: 1;
  transition: all 0.3s ease;
}

/* Previous line (left of station) */
.station-line-prev {
  right: 50%;
  margin-right: 16px;
}

/* Next line (right of station) */
.station-line-next {
  left: 50%;
  margin-left: 16px;
}

/* Line States */

/* Default (pending) - gray dashed */
.station-line {
  background: repeating-linear-gradient(
    90deg,
    #e5e7eb 0px,
    #e5e7eb 4px,
    transparent 4px,
    transparent 8px
  );
}

/* Completed - green solid */
.station-line.line-completed {
  background: var(--green-grade, #71B956);
}

/* Processing - yellow dashed */
.station-line.line-processing {
  background: repeating-linear-gradient(
    90deg,
    #f59e0b 0px,
    #f59e0b 4px,
    transparent 4px,
    transparent 8px
  );
  animation: line-pulse 1s ease-in-out infinite;
}

@keyframes line-pulse {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.5;
  }
}

/* Station Label */
.station-label {
  margin-top: 8px;
  font-size: 10px;
  font-weight: 500;
  color: #64748b;
  text-align: center;
  max-width: 60px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  line-height: 1.2;
}

/* Completed station label */
.subway-station[data-status="completed"] .station-label {
  color: var(--green-grade, #71B956);
  font-weight: 600;
}

/* Grade Badge */
.station-grade {
  position: absolute;
  top: -6px;
  right: 8px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--green-grade, #71B956);
  color: white;
  font-size: 10px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid white;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  z-index: 3;
}

/* Grade colors */
.station-grade[data-grade="A"] {
  background: var(--green-grade, #71B956);
}

.station-grade[data-grade="B"] {
  background: #84cc16;
}

.station-grade[data-grade="C"] {
  background: #f59e0b;
}

.station-grade[data-grade="D"] {
  background: #f97316;
}

.station-grade[data-grade="F"] {
  background: var(--red-grade, #D63B3B);
}

/* Mobile Optimizations */
@media (max-width: 768px) {
  .subway-progress-container {
    padding: 10px 12px;
  }

  .subway-station {
    min-width: 52px;
  }

  .station-circle {
    width: 28px;
    height: 28px;
    font-size: 12px;
    border-width: 2.5px;
  }

  .station-line {
    width: 24px;
    top: 14px;
  }

  .station-line-prev {
    margin-right: 14px;
  }

  .station-line-next {
    margin-left: 14px;
  }

  .station-label {
    font-size: 9px;
    max-width: 52px;
  }

  .station-grade {
    width: 16px;
    height: 16px;
    font-size: 9px;
    top: -4px;
    right: 6px;
  }

  .subway-progress-header {
    font-size: 12px;
    margin-bottom: 10px;
  }

  .progress-percentage {
    font-size: 14px;
  }
}

/* Small phones */
@media (max-width: 375px) {
  .subway-station {
    min-width: 48px;
  }

  .station-circle {
    width: 24px;
    height: 24px;
    font-size: 10px;
  }

  .station-line {
    width: 22px;
    top: 12px;
  }

  .station-line-prev {
    margin-right: 12px;
  }

  .station-line-next {
    margin-left: 12px;
  }

  .station-label {
    font-size: 8px;
    max-width: 48px;
  }
}

/* Accessibility - Focus states */
.subway-station:focus-visible {
  outline: 2px solid var(--green-grade, #71B956);
  outline-offset: 4px;
  border-radius: 4px;
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  .station-circle,
  .station-line,
  .subway-station {
    transition: none;
  }

  .subway-station[data-status="processing"] .station-circle {
    animation: none;
  }

  .station-line.line-processing {
    animation: none;
  }

  @keyframes pulse-complete {
    0%, 100% {
      transform: none;
    }
  }
}

/* High contrast mode */
@media (prefers-contrast: high) {
  .station-circle {
    border-width: 4px;
  }

  .station-line {
    height: 4px;
  }

  .station-label {
    font-weight: 600;
  }
}

/* Hidden state for when progress bar shouldn't show */
.subway-progress-container.hidden {
  display: none;
}

/* P0 FIX: Hide subway progress when camera is active */
/* Camera section visible = hide subway progress */
#cameraSectionZones:not(.hidden) ~ #subway-progress-root .subway-progress-container,
.camera-view:not(.hidden) ~ #subway-progress-root .subway-progress-container {
  display: none;
}

/* Also hide when any fullscreen camera mode is active */
body.camera-active #subway-progress-root {
  display: none;
}

/* Loading skeleton state */
.subway-progress-container.loading .station-circle {
  background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
  background-size: 200% 100%;
  animation: skeleton-loading 1.5s infinite;
}

@keyframes skeleton-loading {
  0% {
    background-position: 200% 0;
  }
  100% {
    background-position: -200% 0;
  }
}
