/* TinyJS Custom Styles - Extreme Minimalist Black-White-Gray Aesthetic */

/* Font imports - System fonts preferred */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

/* Root variables - Pure Grayscale System with Enhanced Spacing */
:root {
  /* Spacing System - Enhanced 8px Grid with Fine Control */
  --space-xxs: 2px;   /* Icon-text gap, Badge padding */
  --space-xs: 4px;    /* Tight inline spacing */
  --space-sm: 8px;    /* Regular padding, list item spacing */
  --space-md: 16px;   /* Card padding, block spacing */
  --space-lg: 24px;   /* Large block spacing, panel margins */
  --space-xl: 32px;   /* Page-level spacing */
  --space-2xl: 48px;  /* Hero spacing */
  --space-3xl: 64px;  /* Extra large spacing */
  --space-4xl: 80px;  /* Feature sections */
  --space-5xl: 120px; /* Major sections */
  
  /* Timing Functions */
  --timing-instant: 100ms;
  --timing-fast: 150ms;
  --timing-normal: 250ms;
  --timing-slow: 400ms;
  --timing-deliberate: 600ms;
  --timing-skeleton: 1200ms;
  
  /* Easing Curves */
  --ease-out: cubic-bezier(0.25, 0.1, 0.25, 1);
  --ease-in: cubic-bezier(0.42, 0, 1, 1);
  --ease-in-out: cubic-bezier(0.42, 0, 0.58, 1);
  --ease-sharp: cubic-bezier(0.4, 0, 0.6, 1);
  --ease-smooth: cubic-bezier(0.4, 0, 0.2, 1);
  
  /* Grayscale Palette - Light Mode */
  --color-white: #FFFFFF;
  --color-gray-50: #FAFAFA;
  --color-gray-100: #F5F5F5;
  --color-gray-200: #E5E5E5;
  --color-gray-400: #A3A3A3;
  --color-gray-500: #737373;
  --color-gray-600: #525252;
  --color-gray-700: #404040;
  --color-gray-900: #171717;
  --color-black: #0A0A0A;
  --color-pure-black: #000000;
  
  /* Semantic Colors - Light Mode */
  --fg-primary: var(--color-black);
  --fg-secondary: var(--color-gray-700);
  --fg-tertiary: var(--color-gray-500);
  --fg-quaternary: var(--color-gray-400);
  
  --bg-base: var(--color-white);
  --bg-subtle: var(--color-gray-50);
  --bg-muted: var(--color-gray-100);
  --bg-emphasis: var(--color-gray-200);
  
  --border-default: var(--color-gray-200);
  --border-strong: var(--color-gray-400);
  --border-emphasis: var(--color-black);
  
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.12);
  
  /* Typography System */
  --font-sans: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", "Roboto", "Helvetica Neue", Arial, sans-serif;
  --font-mono: "SF Mono", "Cascadia Code", "Fira Code", "JetBrains Mono", Menlo, Monaco, "Courier New", monospace;
  
  /* Font Sizes */
  --text-xs: 11px;
  --text-sm: 13px;
  --text-base: 14px;
  --text-lg: 16px;
  --text-xl: 20px;
  --text-2xl: 24px;
  --text-3xl: 32px;
  --text-4xl: 48px;
  --text-5xl: 64px;
  --text-hero: 96px;
  
  /* Font Weights */
  --font-normal: 400;
  --font-medium: 500;
  --font-semibold: 600;
  --font-bold: 700;
  --font-extrabold: 800;
  
  /* Line Heights */
  --leading-tight: 1.0;
  --leading-snug: 1.3;
  --leading-normal: 1.4;
  --leading-relaxed: 1.5;
  --leading-loose: 1.6;
  
  /* Letter Spacing */
  --tracking-tighter: -2px;
  --tracking-tight: -0.5px;
  --tracking-normal: 0;
  --tracking-wide: 0.3px;
  --tracking-wider: 0.5px;
  
  /* Border Radius */
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  --radius-full: 9999px;
  
  /* Z-Index Scale */
  --z-base: 0;
  --z-panel: 1;
  --z-card: 2;
  --z-hover: 3;
  --z-dropdown: 10;
  --z-sticky: 20;
  --z-modal: 100;
  --z-toast: 1000;
}

/* Dark Mode Variables */
.dark {
  /* Grayscale Palette - Dark Mode */
  --color-pure-black: #000000;
  --color-deep-black: #0A0A0A;
  --color-light-black-1: #171717;
  --color-light-black-2: #262626;
  --color-gray-border: #404040;
  --color-gray-disabled: #525252;
  --color-gray-text: #A3A3A3;
  --color-white-text: #FAFAFA;
  
  /* Semantic Colors - Dark Mode */
  --fg-primary: var(--color-white-text);
  --fg-secondary: var(--color-gray-text);
  --fg-tertiary: var(--color-gray-disabled);
  --fg-quaternary: var(--color-gray-border);
  
  --bg-base: var(--color-pure-black);
  --bg-subtle: var(--color-deep-black);
  --bg-muted: var(--color-light-black-1);
  --bg-emphasis: var(--color-light-black-2);
  
  --border-default: var(--color-light-black-2);
  --border-strong: var(--color-gray-border);
  --border-emphasis: var(--color-white-text);
  
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.5);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.7);
}

/* Base styles */
* {
  font-family: var(--font-sans);
}

code, pre, .font-mono {
  font-family: var(--font-mono);
}

/* Smooth scrolling */
html {
  scroll-behavior: smooth;
}

/* Custom scrollbar - Minimal grayscale */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--border-default);
  border-radius: var(--radius-sm);
}

::-webkit-scrollbar-thumb:hover {
  background: var(--border-strong);
}

.dark ::-webkit-scrollbar-thumb {
  background: var(--border-strong);
}

.dark ::-webkit-scrollbar-thumb:hover {
  background: var(--fg-tertiary);
}

/* Pure black/white text - NO GRADIENTS */
.text-black {
  color: var(--fg-primary);
  font-weight: var(--font-bold);
}

/* Glass morphism effect - Minimal */
.glass {
  background: rgba(255, 255, 255, 0.8);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-default);
}

.dark .glass {
  background: rgba(0, 0, 0, 0.8);
  border-bottom: 1px solid var(--border-default);
}

/* Primary Button - Pure Black/White */
.btn-primary {
  background: var(--fg-primary);
  color: var(--bg-base);
  font-weight: var(--font-semibold);
  border-radius: var(--radius-md);
  transition: all var(--timing-fast) var(--ease-out);
  border: none;
}

.btn-primary:hover {
  opacity: 0.85;
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.dark .btn-primary {
  background: var(--fg-primary);
  color: var(--bg-base);
}

.dark .btn-primary:hover {
  box-shadow: 0 4px 12px rgba(255, 255, 255, 0.08);
}

.btn-primary:active {
  transform: translateY(0);
}

/* Button disabled state */
.btn-primary:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
}

/* Button loading state */
.btn-primary.loading {
  pointer-events: none;
  opacity: 0.7;
}

/* Outline Button - Fine Border */
.btn-outline {
  border: 1px solid var(--border-default);
  color: var(--fg-primary);
  background: transparent;
  font-weight: var(--font-semibold);
  border-radius: var(--radius-md);
  transition: all var(--timing-fast) var(--ease-out);
}

.btn-outline:hover {
  background: var(--bg-subtle);
  border-color: var(--fg-secondary);
}

.dark .btn-outline {
  border-color: var(--border-strong);
}

.dark .btn-outline:hover {
  background: var(--bg-muted);
  border-color: var(--fg-secondary);
}

/* Card hover effects - Minimal elevation */
.card-hover {
  transition: all var(--timing-normal) var(--ease-out);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
}

.card-hover:hover {
  transform: translateY(-4px);
  border-color: var(--fg-secondary);
  box-shadow: var(--shadow-sm);
}

.dark .card-hover:hover {
  border-color: var(--fg-tertiary);
  box-shadow: var(--shadow-md);
}

/* Icon animations - Restrained */
.icon-rotate {
  transition: transform var(--timing-slow) var(--ease-in-out);
}

.icon-rotate:hover {
  transform: rotate(180deg);
}

/* Focus styles for accessibility */
*:focus-visible {
  outline: 2px solid var(--fg-primary);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

/* Monaco editor container */
#editor {
  height: 100%;
  width: 100%;
}

/* Console output styling */
.console-output {
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  line-height: var(--leading-loose);
  white-space: pre-wrap;
  word-wrap: break-word;
}

/* Error message styling - NO RED BACKGROUNDS */
.error-message {
  border-left: 2px solid var(--fg-primary);
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  background: var(--bg-subtle);
}

/* Success message styling */
.success-message {
  border-left: 2px solid var(--fg-primary);
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  background: var(--bg-subtle);
}

/* Editor toolbar - Minimal hierarchy */
.editor-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-sm) var(--space-md);
  background-color: var(--bg-subtle);
  border-bottom: 1px solid var(--border-default);
  min-height: 56px;
}

/* Sidebar active state - Pure grayscale */
.sidebar-item-active {
  background: var(--bg-muted);
  color: var(--fg-primary);
  border-left: 2px solid var(--fg-primary) !important;
  font-weight: var(--font-semibold);
}

/* Sidebar item hover */
.sidebar-item {
  transition: all var(--timing-fast) var(--ease-out);
  cursor: pointer;
  border-left: 2px solid transparent;
}

.sidebar-item:hover {
  background-color: var(--bg-subtle);
  border-left-color: var(--fg-tertiary);
}

/* Difficulty badges - Grayscale only */
.badge-easy {
  background-color: var(--bg-muted);
  color: var(--fg-secondary);
  padding: var(--space-xxs) var(--space-sm);
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  font-weight: var(--font-semibold);
  border: 1px solid var(--border-default);
  display: inline-block;
}

.badge-medium {
  background-color: var(--bg-subtle);
  color: var(--fg-primary);
  padding: var(--space-xxs) var(--space-sm);
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  font-weight: var(--font-semibold);
  border: 1px solid var(--fg-secondary);
  display: inline-block;
}

.badge-hard {
  background-color: var(--fg-primary);
  color: var(--bg-base);
  padding: var(--space-xxs) var(--space-sm);
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  font-weight: var(--font-semibold);
  display: inline-block;
}

/* Loading animation */
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.animate-spin {
  animation: spin 1s linear infinite;
}

/* Fade in animation - Restrained */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.fade-in {
  animation: fadeIn var(--timing-deliberate) var(--ease-out);
}

/* Skeleton loading animation */
@keyframes shimmer {
  0% {
    background-position: -1000px 0;
  }
  100% {
    background-position: 1000px 0;
  }
}

.skeleton {
  background: linear-gradient(
    90deg,
    var(--bg-muted) 0%,
    var(--bg-emphasis) 50%,
    var(--bg-muted) 100%
  );
  background-size: 1000px 100%;
  animation: shimmer var(--timing-skeleton) linear infinite;
  border-radius: var(--radius-sm);
}

/* Category header styling */
.category-header {
  position: relative;
  padding-left: var(--space-md);
}

.category-header::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 16px;
  background: var(--fg-primary);
  border-radius: var(--radius-sm);
}

/* Console line styling */
.console-line {
  padding: var(--space-xs) 0;
  border-left: 3px solid transparent;
  padding-left: var(--space-sm);
  transition: all var(--timing-fast) var(--ease-out);
}

.console-line:hover {
  background: var(--bg-subtle);
  border-left-color: var(--fg-quaternary);
}

/* Selection styling - Grayscale only */
::selection {
  background-color: var(--bg-emphasis);
  color: var(--fg-primary);
}

.dark ::selection {
  background-color: var(--border-strong);
  color: var(--fg-primary);
}

/* Link styles - Grayscale */
a {
  color: var(--fg-secondary);
  text-decoration: none;
  transition: color var(--timing-fast) var(--ease-out);
}

a:hover {
  color: var(--fg-primary);
}

/* Navigation link hover effect */
.nav-link {
  position: relative;
  padding-bottom: var(--space-xs);
}

.nav-link::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  width: 0;
  height: 2px;
  background: var(--fg-primary);
  transition: width var(--timing-normal) var(--ease-out);
}

.nav-link:hover::after {
  width: 100%;
}

/* Accessibility Enhancements */
/* Skip to main content link */
.skip-to-main {
  position: absolute;
  top: -40px;
  left: 0;
  background: var(--fg-primary);
  color: var(--bg-base);
  padding: var(--space-sm) var(--space-md);
  text-decoration: none;
  z-index: var(--z-modal);
  border-radius: var(--radius-sm);
}

.skip-to-main:focus {
  top: var(--space-sm);
}

/* Ensure sufficient color contrast */
/* Light mode contrast ratios:
 * - Pure black (#0A0A0A) on white (#FFFFFF): 21:1 ✓
 * - Dark gray (#404040) on white: 10.7:1 ✓
 * - Medium gray (#737373) on white: 4.6:1 ✓
 */

/* Dark mode contrast ratios:
 * - Pure white (#FAFAFA) on black (#000000): 20.8:1 ✓
 * - Light gray (#A3A3A3) on black: 8.3:1 ✓
 */

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

/* Responsive utilities */
@media (max-width: 640px) {
  /* Mobile: Stack layout */
  #sidebar {
    position: fixed;
    top: 64px;
    left: -100%;
    width: 80%;
    max-width: 320px;
    height: calc(100vh - 64px);
    z-index: var(--z-modal);
    transition: left var(--timing-normal) var(--ease-out);
  }
  
  #sidebar.open {
    left: 0;
    box-shadow: var(--shadow-lg);
  }
  
  .mobile-hidden {
    display: none;
  }
  
  .mobile-full-width {
    width: 100%;
  }
  
  /* Hide output panel on mobile by default */
  aside[aria-label="运行结果"] {
    display: none;
  }
  
  /* Adjust spacing for mobile */
  :root {
    --space-lg: 16px;
    --space-xl: 24px;
    --space-2xl: 32px;
  }
}

@media (max-width: 768px) {
  .mobile-hidden {
    display: none;
  }
  
  .mobile-full-width {
    width: 100%;
  }
  
  /* Hero responsive */
  h1[style*="96px"] {
    font-size: 56px !important;
  }
  
  h1[style*="32px"] {
    font-size: 24px !important;
  }
}

/* Tablet breakpoint */
@media (min-width: 768px) and (max-width: 1023px) {
  .tablet-stack {
    flex-direction: column;
  }
}

/* Desktop breakpoint */
@media (min-width: 1024px) {
  .desktop-grid {
    display: grid;
  }
}

/* Large desktop */
@media (min-width: 1280px) {
  .container-max {
    max-width: 1280px;
    margin: 0 auto;
  }
}

/* Extra large desktop */
@media (min-width: 1536px) {
  .container-max {
    max-width: 1600px;
  }
}

/* Print styles */
@media print {
  .no-print {
    display: none;
  }
}

/* Loading animation */
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.animate-spin {
  animation: spin 1s linear infinite;
}

/* Toast notification styles */
.toast {
  position: fixed;
  bottom: var(--space-lg);
  right: var(--space-lg);
  background: var(--fg-primary);
  color: var(--bg-base);
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  z-index: var(--z-toast);
  font-size: var(--text-sm);
  font-weight: var(--font-medium);
  transition: opacity var(--timing-normal) var(--ease-out);
  max-width: 400px;
}

.dark .toast {
  background: var(--fg-primary);
  color: var(--bg-base);
}

/* State indicators */
.state-idle {
  opacity: 1;
}

.state-loading {
  opacity: 0.7;
  pointer-events: none;
}

.state-success {
  border-color: var(--fg-primary);
  animation: flash-border var(--timing-normal) ease-out;
}

.state-error {
  animation: shake var(--timing-normal) ease-out;
}

@keyframes flash-border {
  0%, 100% {
    border-color: var(--border-default);
  }
  50% {
    border-color: var(--fg-primary);
  }
}

@keyframes shake {
  0%, 100% {
    transform: translateX(0);
  }
  25% {
    transform: translateX(-8px);
  }
  75% {
    transform: translateX(8px);
  }
}
