/* Reciplier styles - converted from CSS modules */
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, 
    'Segoe UI', 'Roboto', 'Oxygen',
    'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
    sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* General Layout */
.reciplier-container {
  padding: 1rem;
  max-width: 42rem;
  margin-left: auto;
  margin-right: auto;
}

.mb-2 { margin-bottom: 0.5rem; }
.mb-4 { margin-bottom: 1rem; }
.mb-6 { margin-bottom: 1.5rem; }
.mr-2 { margin-right: 0.5rem; }
.ml-2 { margin-left: 0.5rem; }
.mx-1 { margin-left: 0.25rem; margin-right: 0.25rem; }
.mt-1 { margin-top: 0.25rem; }
.mt-4 { margin-top: 1rem; }

.p-1 { padding: 0.25rem; }
.p-2 { padding: 0.5rem; }
.p-3 { padding: 0.75rem; }
.p-4 { padding: 1rem; }
.px-1 { padding-left: 0.25rem; padding-right: 0.25rem; }
.px-3 { padding-left: 0.75rem; padding-right: 0.75rem; }
.py-0-5 { padding-top: 0.125rem; padding-bottom: 0.125rem; }
.py-2 { padding-top: 0.5rem; padding-bottom: 0.5rem; }

/* Typography */
.text-2xl { font-size: 1.5rem; line-height: 2rem; }
.text-base { font-size: 1rem; line-height: 1.5rem; }
.text-sm { font-size: 0.875rem; line-height: 1.25rem; }
.text-xs { font-size: 0.75rem; line-height: 1rem; }
.font-bold { font-weight: 700; }
.font-medium { font-weight: 600; }
.font-mono { font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas,
                          "Liberation Mono", "Courier New", monospace; }
.text-center { text-align: center; }
.text-gray-400 { color: #9ca3af; }
.text-gray-600 { color: #4b5563; }
.text-gray-700 { color: #374151; }
.text-gray-800 { color: #1f2937; }
.text-gray-300 { color: #d1d5db; }

/* Flexbox */
.flex { display: flex; }
.flex-grow { flex-grow: 1; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.inline-flex { display: inline-flex; }

/* Backgrounds and Borders */
.bg-gray-50 { background-color: #f9fafb; }
.bg-gray-100 { background-color: #f3f4f6; }
.bg-gray-200 { background-color: #e5e7eb; }
.border { border-width: 1px; border-color: #e5e7eb; }
.rounded { border-radius: 0.25rem; }
.rounded-lg { border-radius: 0.5rem; }

/* Inputs */
textarea, select, input[type="text"], input[type="range"] {
  border: 1px solid #e5e7eb;
  border-radius: 0.25rem;
  box-sizing: border-box;
}

textarea {
  height: 10rem;
  width: 100%;
  padding: 0.75rem;
}

select {
  padding: 0.5rem;
}

input[type="text"] {
  width: 5rem;
  padding: 0.25rem;
  text-align: center;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

input[type="text"].invalid {
  border-color: #ef4444;
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.2);
}

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  height: 0.5rem;
  border-radius: 0.5rem;
  cursor: pointer;
  flex-grow: 1;
  /* Background set dynamically via updateSliderFill() in JavaScript */
}

input[type="range"]::-webkit-slider-thumb {
  appearance: none;
  width: 1rem;
  height: 1rem;
  background-color: #3b82f6;
  border-radius: 50%;
  transition: background-color 0.2s ease;
}

input[type="range"]::-moz-range-thumb {
  width: 1rem;
  height: 1rem;
  background-color: #3b82f6;
  border-radius: 50%;
  border: none;
  transition: background-color 0.2s ease;
}

/* Green thumb when at base value */
input[type="range"].at-bass::-webkit-slider-thumb {
  background-color: #10b981;
}

input[type="range"].at-bass::-moz-range-thumb {
  background-color: #10b981;
}

/* Red glowy comet when slider value is outside bounds (like Mathematica Manipulate) */
/* Below min: comet trail pointing right (toward the boundary) */
input[type="range"].out-of-bounds-low::-webkit-slider-thumb {
  box-shadow: 0 0 10px 3px rgba(239, 68, 68, 0.7),
              10px 0 16px 4px rgba(239, 68, 68, 0.6);
}
input[type="range"].out-of-bounds-low::-moz-range-thumb {
  box-shadow: 0 0 10px 3px rgba(239, 68, 68, 0.7),
              10px 0 16px 4px rgba(239, 68, 68, 0.6);
}

/* Above max: comet trail pointing left (toward the boundary) */
input[type="range"].out-of-bounds-high::-webkit-slider-thumb {
  box-shadow: 0 0 10px 3px rgba(239, 68, 68, 0.7),
              -10px 0 16px 4px rgba(239, 68, 68, 0.6);
}
input[type="range"].out-of-bounds-high::-moz-range-thumb {
  box-shadow: 0 0 10px 3px rgba(239, 68, 68, 0.7),
              -10px 0 16px 4px rgba(239, 68, 68, 0.6);
}

/* Disabled slider when no x variable */
input[type="range"].disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

input[type="range"].disabled::-webkit-slider-thumb {
  background-color: #9ca3af;
}

input[type="range"].disabled::-moz-range-thumb {
  background-color: #9ca3af;
}

.text-sm.disabled {
  color: #9ca3af;
}

/* Buttons */
button {
  font-size: 0.875rem;
  padding: 0.5rem 0.75rem;
  border-radius: 0.25rem;
  background-color: #f3f4f6;
  color: #1f2937;
  cursor: pointer;
  border: none;
}

button:hover {
  background-color: #e5e7eb;
}

button:disabled {
  background-color: #f3f4f6;
  color: #9ca3af;
  cursor: not-allowed;
}


.help-float {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 50;
}

.help-button {
  position: relative;
  width: 2rem;
  height: 2rem;
  border-radius: 9999px;
  border: 1px solid #d1d5db;
  background-color: #ffffff;
  color: #374151;
  font-weight: 600;
  line-height: 2rem;
  text-align: center;
  padding: 0;
}

.help-button:hover {
  background-color: #f9fafb;
}

.help-button:focus {
  outline: none;
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}

.help-popover {
  position: absolute;
  right: 0;
  top: 2.5rem;
  width: min(32rem, calc(100vw - 2rem));
  border: 1px solid #d1d5db;
  background-color: #ffffff;
  border-radius: 0.5rem;
  padding: 0.75rem;
  z-index: 10;
}

.help-popover-inner a {
  text-decoration: underline;
}

/* Constants */
.constant {
  background-color: #f3f4f6;
  color: #374151;
  padding: 0.125rem 0.25rem;
  border-radius: 0.25rem;
}

/* Recipe Output */
.recipe-output {
  background-color: #f9fafb;
  padding: 1rem;
  border-radius: 0.25rem;
}

.recipe-rendered {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas,
               "Liberation Mono", "Courier New", monospace;
  line-height: 1.8;
}

/* Recipe input fields */
.recipe-field {
  width: 4.5rem;
  padding: 0.125rem 0.25rem;
  margin: 0 0.125rem;
  border: 1px solid #d1d5db;
  border-radius: 0.25rem;
  text-align: center;
  font-family: inherit;
  font-size: inherit;
  background-color: #fff;
  transition: border-color 0.15s, box-shadow 0.15s, background-color 0.15s;
}

.recipe-field:focus {
  outline: none;
  border-color: #3b82f6;
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}

.recipe-field.invalid {
  border-color: #ef4444;
  background-color: #fef2f2;
  box-shadow: 0 0 0 2px rgba(239, 68, 68, 0.2);
}

.recipe-field.pegged {
  background-color: #dbeafe;
  border-color: #3b82f6;
  font-weight: 600;
}

.recipe-field.pressing {
  background-color: #e5e7eb;
  transition: background-color 0.1s ease;
}

/* Inline sliders for cells with inequality bounds */
/* Each line is wrapped in a span; lines with sliders become inline-flex containers */
/* (inline-flex keeps the span inline-level so <br> works normally after it) */
.recipe-line:has(.recipe-slider) {
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 1em;
  width: 100%;
}

.slider-group {
  display: inline-flex;
  align-items: center;
  flex-grow: 1;
  min-width: 4rem;
  gap: 0.375rem;
}

.recipe-slider {
  flex-grow: 1;
  min-width: 2rem;
  height: 0.5rem;
}

.slider-bound {
  font-size: 0.75rem;
  color: #6b7280;
  white-space: nowrap;
}

/* Error display */
.error-display {
  padding: 1rem;
}

.error-message {
  color: #dc2626;
  padding: 0.5rem;
  margin-bottom: 0.5rem;
  background-color: #fef2f2;
  border-radius: 0.25rem;
  border: 1px solid #fecaca;
}

.debug-values {
  color: #6b7280;
  font-size: 0.8rem;
  padding: 0.5rem;
  margin-top: 0.5rem;
  background-color: #f3f4f6;
  border-radius: 0.25rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

.w-20 { width: 5rem; }
.w-full { width: 100%; }
.h-2 { height: 0.5rem; }
.h-40 { height: 10rem; }

/* Notification styles */
.notification {
  background-color: #f3f4f6;
  color: #1f2937;
  padding: 0.5rem 1rem;
  border-radius: 0.25rem;
  text-align: center;
  animation: fadeIn 0.2s ease-in;
}

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

/* Hover styles for links */
a:hover {
  color: #4b5563;
  text-decoration: underline;
}

.relative { position: relative; }

/* Temporary Debug Panel */
.debug-panel {
  margin-top: 2rem;
  padding: 1rem;
  border: 2px dashed #f59e0b;
  border-radius: 0.5rem;
  background-color: #fffbeb;
}

/* Native <summary> element styling with custom chevron */
.debug-header {
  font-weight: 700;
  color: #b45309;
  font-size: 0.875rem;
  cursor: pointer;
  user-select: none;
  transition: color 0.15s;
  padding: 0.25rem 0;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* Hide default marker in Safari */
.debug-header::-webkit-details-marker {
  display: none;
}

/* Custom chevron using ::before */
.debug-header::before {
  content: '▶';
  font-size: 0.65rem;
  transition: transform 0.2s ease;
}

/* Rotate chevron when open */
.debug-panel[open] .debug-header::before {
  transform: rotate(90deg);
}

.debug-header:hover {
  color: #92400e;
}

/* When panel is open, add margin below header */
.debug-panel[open] .debug-header {
  margin-bottom: 1rem;
}

.debug-content {
  /* Content wrapper */
}

.debug-section {
  margin-bottom: 0.75rem;
}

.debug-section:last-child {
  margin-bottom: 0;
}

.debug-label {
  font-size: 0.875rem;
  color: #374151;
  margin-bottom: 0.25rem;
}

.debug-hint {
  font-size: 0.7rem;
  color: #9ca3af;
  margin-top: 0.25rem;
  font-style: italic;
}

.debug-options {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
}

.debug-options label {
  font-size: 0.875rem;
  color: #4b5563;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.debug-panel input[type="range"] {
  width: 100%;
  margin-top: 0.25rem;
}

/* =============================================================================
   Visual Peg Trigger Modes
   ============================================================================= */

/* Field wrapper for visual trigger elements */
.field-wrapper {
  position: relative;
  display: inline-block;
  vertical-align: middle;
}

/* --- Corner Pin Mode --- */
.corner-pin {
  position: absolute;
  top: -6px;
  right: -6px;
  width: 18px;
  height: 18px;
  font-size: 12px;
  line-height: 18px;
  text-align: center;
  background-color: #f3f4f6;
  border: 1px solid #d1d5db;
  border-radius: 50%;
  cursor: pointer;
  user-select: none;
  z-index: 10;
  transition: background-color 0.15s, transform 0.15s, box-shadow 0.15s;
}

.corner-pin:hover {
  background-color: #e5e7eb;
  transform: scale(1.15);
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.corner-pin.pegged {
  background-color: #dbeafe;
  border-color: #3b82f6;
  color: #dc2626;
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.3);
}

/* --- Edge Dots Mode --- */
.edge-dot {
  position: absolute;
  width: 6px;
  height: 6px;
  background-color: #9ca3af;
  border-radius: 50%;
  cursor: pointer;
  z-index: 10;
  transition: background-color 0.15s, transform 0.15s;
}

.edge-dot:hover {
  background-color: #6b7280;
  transform: scale(1.3);
}

.edge-dot.pegged {
  background-color: #3b82f6;
}

.edge-dot.top {
  top: -3px;
  left: 50%;
  transform: translateX(-50%);
}
.edge-dot.top:hover {
  transform: translateX(-50%) scale(1.3);
}

.edge-dot.right {
  right: -3px;
  top: 50%;
  transform: translateY(-50%);
}
.edge-dot.right:hover {
  transform: translateY(-50%) scale(1.3);
}

.edge-dot.bottom {
  bottom: -3px;
  left: 50%;
  transform: translateX(-50%);
}
.edge-dot.bottom:hover {
  transform: translateX(-50%) scale(1.3);
}

.edge-dot.left {
  left: -3px;
  top: 50%;
  transform: translateY(-50%);
}
.edge-dot.left:hover {
  transform: translateY(-50%) scale(1.3);
}

/* --- Corner Brackets Mode --- */
.corner-bracket {
  position: absolute;
  font-size: 14px;
  line-height: 1;
  color: #9ca3af;
  cursor: pointer;
  user-select: none;
  z-index: 10;
  transition: color 0.15s, transform 0.15s;
}

.corner-bracket:hover {
  color: #374151;
  transform: scale(1.2);
}

.corner-bracket.pegged {
  color: #3b82f6;
}

.corner-bracket.top-left {
  top: -6px;
  left: -6px;
}

.corner-bracket.top-right {
  top: -6px;
  right: -6px;
}

.corner-bracket.bottom-left {
  bottom: -6px;
  left: -6px;
}

.corner-bracket.bottom-right {
  bottom: -6px;
  right: -6px;
}

/* --- Hover Glow Mode --- */
.recipe-field.hoverglow-left {
  box-shadow: -4px 0 8px -2px rgba(59, 130, 246, 0.5);
}

.recipe-field.hoverglow-right {
  box-shadow: 4px 0 8px -2px rgba(59, 130, 246, 0.5);
}

.recipe-field.hoverglow-top {
  box-shadow: 0 -4px 8px -2px rgba(59, 130, 246, 0.5);
}

.recipe-field.hoverglow-bottom {
  box-shadow: 0 4px 8px -2px rgba(59, 130, 246, 0.5);
}

/* =============================================================================
   Focus-Only Visibility for Indicators
   ============================================================================= */

/* Visual elements (pins, dots, brackets) hidden by default when focus-only */
.focus-only {
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease;
}

/* Also show on hover for discoverability */
.field-wrapper:hover .focus-only {
  opacity: 0.6;
  pointer-events: auto;
}

.field-wrapper:hover .focus-only:hover {
  opacity: 1;
}

/* Show visual elements when field is focused (takes precedence over hover) */
.field-wrapper:focus-within .focus-only {
  opacity: 1;
  pointer-events: auto;
}

/* Blue background focus-only mode */
.recipe-field.pegged.focus-only-bg {
  background-color: #fff;
  border-color: #d1d5db;
  font-weight: normal;
}

.recipe-field.pegged.focus-only-bg:focus {
  background-color: #dbeafe;
  border-color: #3b82f6;
  font-weight: 600;
}
