/* Lattice Percolation Visualization */
:root {
  --lp-primary: #3b82f6;
  --lp-secondary: #8b5cf6;
  --lp-accent: #10b981;
  --lp-danger: #ef4444;
  --lp-warning: #f59e0b;
  --lp-bg: #0f172a;
  --lp-surface: #1e293b;
  --lp-surface-hover: #334155;
  --lp-border: #334155;
  --lp-text: #f1f5f9;
  --lp-text-muted: #94a3b8;
  --lp-shadow: rgba(0, 0, 0, 0.3);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: var(--lp-bg);
  color: var(--lp-text);
  line-height: 1.6;
}

.lp-container {
  max-width: 1800px;
  margin: 0 auto;
  padding: 1rem;
}

/* Header */
.lp-header {
  text-align: center;
  padding: 2rem 1rem;
  border-bottom: 1px solid var(--lp-border);
  margin-bottom: 2rem;
}

.lp-title {
  font-size: 2.5rem;
  font-weight: 700;
  background: linear-gradient(135deg, var(--lp-primary), var(--lp-secondary));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 0.5rem;
}

.lp-subtitle {
  font-size: 1.1rem;
  color: var(--lp-text-muted);
}

/* Main Layout */
.lp-main {
  display: grid;
  grid-template-columns: 300px 1fr 280px;
  gap: 1.5rem;
  margin-bottom: 3rem;
}

/* Panels */
.lp-controls-panel,
.lp-info-panel {
  background: var(--lp-surface);
  border-radius: 12px;
  padding: 1.5rem;
  border: 1px solid var(--lp-border);
  height: fit-content;
  position: sticky;
  top: 1rem;
}

.lp-control-section,
.lp-info-section {
  margin-bottom: 1.5rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--lp-border);
}

.lp-control-section:last-child,
.lp-info-section:last-child {
  border-bottom: none;
  margin-bottom: 0;
  padding-bottom: 0;
}

.lp-control-section h2,
.lp-info-section h2 {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 1rem;
  color: var(--lp-primary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* Controls */
.lp-slider-group {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1rem;
}

.lp-slider {
  flex: 1;
  height: 8px;
  background: var(--lp-bg);
  border-radius: 4px;
  outline: none;
  -webkit-appearance: none;
}

.lp-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 20px;
  height: 20px;
  background: var(--lp-primary);
  border-radius: 50%;
  cursor: pointer;
  transition: transform 0.2s;
}

.lp-slider::-webkit-slider-thumb:hover {
  transform: scale(1.2);
}

.lp-slider::-moz-range-thumb {
  width: 20px;
  height: 20px;
  background: var(--lp-primary);
  border: none;
  border-radius: 50%;
  cursor: pointer;
}

.lp-prob-value {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--lp-accent);
  min-width: 60px;
  text-align: right;
}

.lp-prob-info {
  font-size: 0.9rem;
  color: var(--lp-text-muted);
  padding: 0.75rem;
  background: var(--lp-bg);
  border-radius: 8px;
  border: 1px solid var(--lp-border);
}

.lp-select {
  width: 100%;
  padding: 0.75rem;
  background: var(--lp-bg);
  border: 1px solid var(--lp-border);
  border-radius: 8px;
  color: var(--lp-text);
  font-size: 0.95rem;
  cursor: pointer;
  transition: border-color 0.2s;
}

.lp-select:hover {
  border-color: var(--lp-primary);
}

.lp-select:focus {
  outline: none;
  border-color: var(--lp-primary);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.lp-param-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.lp-param-row label {
  font-size: 0.9rem;
  color: var(--lp-text-muted);
  flex: 1;
}

.lp-checkbox {
  width: 20px;
  height: 20px;
  cursor: pointer;
}

.lp-color-input {
  width: 50px;
  height: 35px;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  background: none;
}

.lp-button-group {
  display: flex;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.lp-btn {
  flex: 1;
  padding: 0.75rem 1rem;
  border: none;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.lp-btn-primary {
  background: var(--lp-primary);
  color: white;
}

.lp-btn-primary:hover {
  background: #2563eb;
  transform: translateY(-1px);
}

.lp-btn-secondary {
  background: var(--lp-surface-hover);
  color: var(--lp-text);
}

.lp-btn-secondary:hover {
  background: #475569;
}

.lp-btn-reset {
  width: 100%;
  background: var(--lp-danger);
  color: white;
}

.lp-btn-reset:hover {
  background: #dc2626;
}

/* Visualization */
.lp-viz-container {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.lp-canvas-wrapper {
  position: relative;
  background: var(--lp-surface);
  border-radius: 12px;
  border: 1px solid var(--lp-border);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 500px;
}

.lp-canvas {
  display: block;
  max-width: 100%;
  max-height: 600px;
}

.lp-legend {
  position: absolute;
  top: 1rem;
  right: 1rem;
  background: rgba(15, 23, 42, 0.9);
  padding: 0.75rem 1rem;
  border-radius: 8px;
  border: 1px solid var(--lp-border);
  font-size: 0.85rem;
}

.lp-legend-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.lp-legend-item:last-child {
  margin-bottom: 0;
}

.lp-legend-box {
  width: 16px;
  height: 16px;
  border-radius: 3px;
  border: 1px solid var(--lp-border);
}

.lp-legend-empty {
  background: var(--lp-bg);
}

.lp-legend-occupied {
  background: var(--lp-text);
}

.lp-legend-regular {
  background: var(--lp-primary);
}

.lp-legend-percolating {
  background: var(--lp-accent);
}

/* Statistics Bar */
.lp-stats-bar {
  display: flex;
  justify-content: space-around;
  background: var(--lp-surface);
  padding: 1rem;
  border-radius: 8px;
  border: 1px solid var(--lp-border);
  flex-wrap: wrap;
  gap: 1rem;
}

.lp-stat-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
}

.lp-stat-item span {
  font-size: 0.8rem;
  color: var(--lp-text-muted);
  text-align: center;
}

.lp-stat-item strong {
  font-size: 1.2rem;
  color: var(--lp-accent);
}

/* Info Panel */
.lp-phase-state {
  font-size: 0.9rem;
  line-height: 1.6;
  color: var(--lp-text-muted);
}

.lp-phase-state p {
  margin-bottom: 0.75rem;
}

.lp-phase-state strong {
  color: var(--lp-text);
}

.lp-theory-content {
  font-size: 0.9rem;
  line-height: 1.6;
  color: var(--lp-text-muted);
}

.lp-theory-content p {
  margin-bottom: 0;
}

.lp-applications {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.lp-app-item {
  padding: 0.75rem;
  background: var(--lp-bg);
  border-radius: 6px;
  border-left: 3px solid var(--lp-accent);
}

.lp-app-item strong {
  display: block;
  font-size: 0.95rem;
  color: var(--lp-text);
  margin-bottom: 0.25rem;
}

.lp-app-item p {
  font-size: 0.85rem;
  color: var(--lp-text-muted);
  margin: 0;
}

/* Educational Content */
.lp-education {
  display: grid;
  gap: 2rem;
  margin-top: 3rem;
}

.lp-edu-section {
  background: var(--lp-surface);
  padding: 2rem;
  border-radius: 12px;
  border: 1px solid var(--lp-border);
}

.lp-edu-section h2 {
  font-size: 1.5rem;
  margin-bottom: 1rem;
  color: var(--lp-primary);
}

.lp-edu-section p {
  color: var(--lp-text-muted);
  line-height: 1.8;
  margin-bottom: 1rem;
}

.lp-edu-list {
  list-style: none;
  padding-left: 0;
}

.lp-edu-list li {
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--lp-border);
  color: var(--lp-text-muted);
}

.lp-edu-list li:last-child {
  border-bottom: none;
}

.lp-edu-list strong {
  color: var(--lp-text);
}

/* Steps */
.lp-edu-steps {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.5rem;
  margin-top: 1.5rem;
}

.lp-step {
  background: var(--lp-bg);
  padding: 1.5rem;
  border-radius: 8px;
  border: 1px solid var(--lp-border);
  position: relative;
  overflow: hidden;
}

.lp-step-phase {
  font-size: 1.2rem;
  font-weight: 700;
  margin-bottom: 1rem;
  padding: 0.5rem;
  text-align: center;
  border-radius: 4px;
}

.lp-step-subcritical {
  background: linear-gradient(135deg, #ef4444, #f97316);
  color: white;
}

.lp-step-critical {
  background: linear-gradient(135deg, #f59e0b, #eab308);
  color: white;
}

.lp-step-supercritical {
  background: linear-gradient(135deg, #10b981, #22c55e);
  color: white;
}

.lp-step h3 {
  font-size: 1.1rem;
  margin-bottom: 0.75rem;
  color: var(--lp-accent);
}

.lp-step p {
  font-size: 0.9rem;
  color: var(--lp-text-muted);
  margin-bottom: 0;
  line-height: 1.6;
}

/* Grid */
.lp-edu-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 1.5rem;
  margin-top: 1.5rem;
}

.lp-edu-card {
  background: var(--lp-bg);
  padding: 1.5rem;
  border-radius: 8px;
  border: 1px solid var(--lp-border);
}

.lp-edu-card h3 {
  font-size: 1.1rem;
  margin-bottom: 0.75rem;
  color: var(--lp-accent);
}

.lp-edu-card p {
  font-size: 0.9rem;
  color: var(--lp-text-muted);
  margin-bottom: 0;
  line-height: 1.6;
}

/* Responsive */
@media (max-width: 1200px) {
  .lp-main {
    grid-template-columns: 1fr;
  }

  .lp-controls-panel,
  .lp-info-panel {
    position: static;
  }
}

@media (max-width: 768px) {
  .lp-title {
    font-size: 1.8rem;
  }

  .lp-subtitle {
    font-size: 0.95rem;
  }

  .lp-edu-steps,
  .lp-edu-grid {
    grid-template-columns: 1fr;
  }

  .lp-button-group {
    flex-direction: column;
  }

  .lp-legend {
    position: static;
    margin-top: 1rem;
  }

  .lp-stats-bar {
    flex-direction: column;
    gap: 0.5rem;
  }
}
