/* Odyssey Trace Viewer Styles - Enhanced iTerm2 Theme */

@keyframes trace-spinner-rotation {
  to { transform: rotate(360deg); }
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(-4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes float {
  0%, 100% {
    transform: translateY(0px);
  }
  50% {
    transform: translateY(-10px);
  }
}

/* ========================================
   Mobile & Small Screen Responsive Design
   ======================================== */

/* Tablets and smaller laptops (768px - 1024px) */
@media (max-width: 1024px) {
  /* Training Charts */
  .training-charts-grid > div {
    grid-template-columns: 1fr !important;
  }

  /* Figures */
  figure.l-page img,
  figure.l-body img {
    max-width: 100%;
    height: auto;
  }

  /* Terminal tabs - better scrolling */
  .terminal-tabs {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .terminal-tab {
    min-width: 120px;
    flex-shrink: 0;
  }
}

/* Mobile devices (max 767px) */
@media (max-width: 767px) {
  /* Container adjustments */
  #trace-viewer-container {
    margin: 1.5rem -1rem;
    font-size: 13px;
  }

  /* Terminal window - full width on mobile */
  .terminal-window {
    border-radius: 8px;
    margin: 0;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
  }

  .terminal-header {
    padding: 10px 12px;
    min-height: 40px;
  }

  .terminal-buttons {
    gap: 7px;
    margin-right: 12px;
  }

  .terminal-button {
    width: 11px;
    height: 11px;
  }

  .terminal-title {
    font-size: 12px !important;
    margin-right: 40px;
  }

  /* Tabs - better touch targets */
  .terminal-tabs {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
  }

  .terminal-tabs::-webkit-scrollbar {
    height: 3px;
  }

  .terminal-tabs::-webkit-scrollbar-thumb {
    background: rgba(0,0,0,0.2);
    border-radius: 2px;
  }

  .terminal-tab {
    padding: 10px 14px !important;
    font-size: 12px !important;
    min-width: 110px;
    flex-shrink: 0;
  }

  .terminal-tab.active {
    padding-bottom: 8px;
  }

  /* Content - optimized height and readability */
  .terminal-content {
    padding: 16px !important;
    max-height: 480px !important;
    font-size: 13px;
    line-height: 1.5;
  }

  /* Trace steps - better spacing */
  .trace-step {
    margin-bottom: 12px;
    border-radius: 6px;
  }

  .step-header {
    padding: 12px 14px;
    gap: 10px;
    min-height: 48px;
  }

  .step-collapse-icon {
    font-size: 11px;
    width: 14px;
    flex-shrink: 0;
  }

  .step-icon {
    font-size: 16px;
    flex-shrink: 0;
  }

  .step-label {
    font-size: 11px;
    line-height: 1.4;
  }

  /* Hide preview text on mobile to save space */
  .step-preview {
    display: none !important;
  }

  .step-content-wrapper {
    padding: 0 14px 14px 14px;
  }

  .step-content {
    font-size: 12px;
    line-height: 1.5;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .step-content.thinking,
  .step-content.tool-call,
  .step-content.observation {
    padding: 12px 14px;
    font-size: 12px;
  }

  /* Prevent code from breaking layout */
  .step-content pre,
  .step-content code {
    word-wrap: break-word;
    overflow-wrap: break-word;
    white-space: pre-wrap;
  }

  /* Metadata - stack on mobile */
  .trace-metadata {
    padding: 14px 16px;
    margin-top: 18px;
    margin-bottom: 20px;
    border-radius: 6px;
  }

  .metadata-title {
    font-size: 12px;
    margin-bottom: 12px;
    font-weight: 600;
  }

  .metadata-row {
    flex-direction: column !important;
    gap: 5px !important;
    margin-bottom: 10px;
    padding: 6px 0;
    border-bottom: 1px solid rgba(255,255,255,0.1);
  }

  .metadata-row:last-child {
    border-bottom: none;
  }

  .metadata-label {
    min-width: unset !important;
    font-size: 11px;
    opacity: 0.8;
  }

  .metadata-value {
    font-size: 12px;
    font-weight: 500;
  }

  /* Controls - better touch experience */
  .trace-controls {
    padding: 12px 14px;
    margin-bottom: 14px;
    flex-wrap: wrap;
    gap: 10px;
    border-radius: 6px;
  }

  .control-button {
    padding: 8px 14px;
    font-size: 11px;
    min-height: 40px;
    border-radius: 6px;
  }

  .control-label {
    font-size: 11px;
    width: 100%;
    margin-bottom: 8px;
    font-weight: 600;
  }

  /* Loading and empty states */
  .loading-message,
  .empty-state {
    padding: 50px 24px;
    font-size: 13px;
  }

  .loading-spinner {
    width: 24px;
    height: 24px;
    border-width: 3px;
    margin-bottom: 16px;
  }

  .empty-state-icon {
    font-size: 48px;
    margin-bottom: 16px;
  }

  .empty-state-text {
    font-size: 14px;
    line-height: 1.6;
  }

  /* Step badges */
  .step-badge {
    padding: 3px 7px;
    font-size: 10px;
    letter-spacing: 0.5px;
    border-radius: 4px;
  }

  /* Training Charts - mobile optimized */
  .training-charts-grid {
    margin: 2rem 0 !important;
  }

  .training-charts-grid > div {
    padding: 1.5rem 1.2rem !important;
    margin: 0 0 1.2rem 0 !important;
    border-radius: 12px !important;
  }

  canvas {
    max-height: 260px !important;
    width: 100% !important;
  }
}

/* Small phones (max 480px) - iPhone SE, small Android */
@media (max-width: 480px) {
  #trace-viewer-container {
    margin: 1.2rem -0.8rem;
    font-size: 12px;
  }

  .terminal-window {
    border-radius: 6px;
  }

  .terminal-header {
    padding: 8px 10px;
  }

  .terminal-title {
    display: none;
  }

  .terminal-tab {
    padding: 8px 12px !important;
    font-size: 11px !important;
    min-width: 90px;
  }

  .terminal-content {
    padding: 14px 12px !important;
    max-height: 420px !important;
    font-size: 12px;
  }

  .step-header {
    padding: 10px 12px;
    gap: 8px;
    min-height: 44px;
  }

  .step-label {
    font-size: 10px;
  }

  .step-icon {
    font-size: 14px;
  }

  .metadata-row {
    font-size: 11px;
  }

  .metadata-label {
    font-size: 10px;
  }

  .metadata-value {
    font-size: 11px;
  }

  .control-button {
    font-size: 10px;
    padding: 7px 12px;
    min-height: 38px;
  }

  /* Charts on very small screens */
  canvas {
    max-height: 220px !important;
  }

  .training-charts-grid {
    margin: 1.5rem 0 !important;
  }

  .training-charts-grid > div {
    padding: 1.2rem 1rem !important;
    margin: 0 0 1rem 0 !important;
    border-radius: 10px !important;
  }

  /* Adjust step content for small screens */
  .step-content-wrapper {
    padding: 0 12px 12px 12px;
  }

  .step-content {
    font-size: 11.5px;
  }

  .step-content.thinking,
  .step-content.tool-call,
  .step-content.observation {
    padding: 10px 12px;
    font-size: 11.5px;
  }
}

/* Landscape mobile devices */
@media (max-width: 767px) and (orientation: landscape) {
  .terminal-content {
    max-height: 350px;
  }

  canvas {
    max-height: 220px !important;
  }
}

/* Touch device optimizations */
@media (hover: none) and (pointer: coarse) {
  /* Larger touch targets */
  .terminal-tab {
    padding: 10px 14px;
  }

  .step-header {
    padding: 12px 14px;
    min-height: 44px;
  }

  .control-button {
    padding: 8px 14px;
    min-height: 44px;
  }

  /* Smoother scrolling */
  .terminal-content,
  .terminal-tabs,
  .step-content.observation {
    -webkit-overflow-scrolling: touch;
    scroll-behavior: smooth;
  }
}
