/*
  © 2025 Milos Saric. All rights reserved.
  Mobile-Optimized Interactive Jupyter-like Notebook Styles - FIXED
  Enhanced for touch devices and small screens
  ONLY AFFECTS MOBILE - Desktop unchanged
*/

:root {
  --notebook-bg: #ffffff;
  --cell-bg: #ffffff;
  --cell-border: #e5e5e7;
  --cell-hover-border: #d1d1d6;
  --code-bg: #f6f6f6;
  --code-text: #1d1d1f;
  --output-bg: #fafafa;
  --primary-blue: #007aff;
  --success-green: #30d158;
  --error-red: #ff3b30;
  --text-primary: #1d1d1f;
  --text-secondary: #86868b;
  --shadow-light: 0 2px 8px rgba(0, 0, 0, 0.08);
  --shadow-medium: 0 4px 16px rgba(0, 0, 0, 0.12);
  --radius-small: 8px;
  --radius-medium: 12px;
  --transition-fast: 0.2s ease;
  --transition-smooth: 0.3s ease;
}

/* Dark mode support */
.dark-mode {
  --notebook-bg: #000000;
  --cell-bg: #1c1c1e;
  --cell-border: #38383a;
  --cell-hover-border: #48484a;
  --code-bg: #2c2c2e;
  --code-text: #ffffff;
  --output-bg: #1c1c1e;
  --text-primary: #ffffff;
  --text-secondary: #98989d;
  --shadow-light: 0 2px 8px rgba(0, 0, 0, 0.3);
  --shadow-medium: 0 4px 16px rgba(0, 0, 0, 0.4);
}

/* Loading Overlay */
.loading-overlay,
#pyodide-loading {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  transition: opacity var(--transition-smooth), visibility var(--transition-smooth);
  padding: 1rem;
}

.loading-overlay.hidden,
#pyodide-loading.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.loading-content {
  text-align: center;
  max-width: 90%;
  width: 400px;
  padding: 1.5rem;
}

.loading-spinner {
  width: 50px;
  height: 50px;
  border: 3px solid var(--cell-border);
  border-top: 3px solid var(--primary-blue);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin: 0 auto 1rem;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.loading-content h2 {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 0.5rem;
}

.loading-content p {
  color: var(--text-secondary);
  margin-bottom: 1rem;
  font-size: 0.9rem;
}

.progress-container {
  width: 100%;
  margin: 0 auto;
}

.progress-bar {
  width: 100%;
  height: 6px;
  background: var(--cell-border);
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 0.5rem;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary-blue), #5ac8fa);
  border-radius: 3px;
  width: 0%;
  transition: width 0.3s ease;
}

.progress-text {
  text-align: center;
  font-size: 0.8rem;
  color: var(--text-secondary);
}

/* Toast Messages */
.toast-message {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: var(--cell-bg);
  color: var(--text-primary);
  padding: 0.75rem 1rem;
  border-radius: var(--radius-medium);
  box-shadow: var(--shadow-medium);
  border: 1px solid var(--cell-border);
  z-index: 10000;
  max-width: calc(100% - 2rem);
  font-size: 0.85rem;
  transition: transform var(--transition-smooth);
  -webkit-tap-highlight-color: transparent;
}

.toast-message.show {
  transform: translateX(-50%) translateY(0);
}

.toast-message.error {
  background: var(--error-red);
  color: white;
  border-color: var(--error-red);
}

.toast-message.success {
  background: var(--success-green);
  color: white;
  border-color: var(--success-green);
}

.toast-message.warning {
  background: #ff9500;
  color: white;
  border-color: #ff9500;
}

/* Focus styles for accessibility */
.run-button:focus-visible,
.code-editor:focus-visible {
  outline: 2px solid var(--primary-blue);
  outline-offset: 2px;
}

/* ========================================
   MOBILE ONLY STYLES (max-width: 768px)
   ======================================== */

@media (max-width: 768px) {
  /* Prevent horizontal scroll */
  body {
    overflow-x: hidden;
  }

  /* Force full width on mobile */
  .main-content {
    margin-left: 0 !important;
    width: 100% !important;
    max-width: 100vw;
  }

  /* Hero Section - Mobile */
  .hero-section {
    padding: 60px 1rem 40px;
  }

  .hero-content h1 {
    font-size: 1.5rem;
  }

  .hero-content p {
    font-size: 0.9rem;
  }

  /* Notebook Section - Mobile */
  .notebook-section {
    padding: 1rem 0.5rem;
  }

  .notebook-section .container {
    padding: 0 0.5rem;
  }

  .notebook-cell {
    margin-bottom: 1rem;
  }

  /* Markdown Cells - Mobile */
  .markdown-cell .cell-content {
    padding: 1rem;
  }

  .markdown-cell h1 {
    font-size: 1.4rem;
  }

  .markdown-cell h2 {
    font-size: 1.25rem;
  }

  .markdown-cell h3 {
    font-size: 1.1rem;
  }

  .markdown-cell p {
    font-size: 0.9rem;
  }

  .markdown-cell blockquote {
    padding: 0.75rem;
    font-size: 0.85rem;
  }

  .markdown-cell ul,
  .markdown-cell ol {
    padding-left: 1.25rem;
  }

  .markdown-cell li {
    font-size: 0.9rem;
  }

  /* Tables - Mobile */
  .markdown-cell table {
    font-size: 0.7rem;
  }

  .markdown-cell th,
  .markdown-cell td {
    padding: 0.4rem 0.3rem;
    min-width: 60px;
    font-size: 0.7rem;
  }

  .markdown-cell th {
    font-size: 0.75rem;
  }

  .markdown-cell td code {
    font-size: 0.65rem;
    padding: 0.1rem 0.2rem;
  }

  /* Code Cells - Mobile */
  .cell-header {
    padding: 0.6rem 0.75rem;
  }

  .cell-type {
    font-size: 0.7rem;
  }

  .run-button {
    padding: 0.5rem 0.65rem;
    font-size: 0.8rem;
    min-width: 65px;
  }

  .run-button svg {
    width: 12px;
    height: 12px;
  }

  .code-editor {
    min-height: 80px;
    padding: 0.75rem;
    font-size: 0.75rem;
  }

  .cell-output {
    padding: 0.75rem;
    font-size: 0.75rem;
  }

  /* Safe area insets for notched devices */
  @supports (padding: max(0px)) {
    .notebook-section {
      padding-left: max(0.5rem, env(safe-area-inset-left));
      padding-right: max(0.5rem, env(safe-area-inset-right));
    }
    
    .toast-message {
      bottom: max(20px, env(safe-area-inset-bottom));
    }
  }
}

/* Extra Small Mobile (max-width: 375px) */
@media (max-width: 375px) {
  .hero-section {
    padding: 50px 0.75rem 30px;
  }

  .hero-content h1 {
    font-size: 1.3rem;
  }

  .hero-content p {
    font-size: 0.85rem;
  }

  .notebook-section {
    padding: 0.75rem 0.5rem;
  }

  .markdown-cell .cell-content {
    padding: 0.75rem;
  }

  .markdown-cell h1 {
    font-size: 1.25rem;
  }

  .markdown-cell h2 {
    font-size: 1.15rem;
  }

  .markdown-cell h3 {
    font-size: 1rem;
  }

  .markdown-cell table {
    font-size: 0.65rem;
  }

  .markdown-cell th,
  .markdown-cell td {
    padding: 0.3rem 0.25rem;
    min-width: 50px;
    font-size: 0.65rem;
  }

  .markdown-cell td code {
    font-size: 0.6rem;
  }
}

/* Landscape Mobile */
@media (max-height: 500px) and (orientation: landscape) {
  .hero-section {
    padding: 60px 1rem 30px;
  }

  .hero-content h1 {
    font-size: 1.3rem;
    margin-bottom: 0.5rem;
  }

  .hero-content p {
    font-size: 0.85rem;
    margin-bottom: 0.75rem;
  }

  .notebook-section {
    padding: 1rem 0.5rem;
  }
}

/* Tablet Styles (768px - 1024px) */
@media (min-width: 768px) and (max-width: 1024px) {
  .hero-content h1 {
    font-size: 2rem;
  }

  .notebook-section {
    padding: 2rem 1.5rem;
  }

  .markdown-cell .cell-content {
    padding: 1.5rem;
  }

  .markdown-cell table {
    font-size: 0.85rem;
  }

  .code-editor {
    font-size: 0.85rem;
  }
}

/* Accessibility - Reduced Motion */
@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }

  .loading-spinner {
    animation: none;
  }
}