/* Shared styles extracted from fdm.html */
body {
  margin: 0;
  padding: 10px;
  font-family: sans-serif;
  background-color: #f5f5f5;
  min-height: 100vh;
  box-sizing: border-box;
}
.header {
  text-align: center;
  margin-bottom: 20px;
}
.header h1 {
  margin: 0;
  color: #333;
  font-size: clamp(1.5rem, 4vw, 2rem);
}
.header p {
  margin: 5px 0;
  color: #666;
  font-size: clamp(0.8rem, 2.5vw, 1rem);
}
.header a {
  word-break: break-word;
}
.instructions {
  text-align: center;
  margin-bottom: 20px;
  color: #666;
  font-size: clamp(0.9rem, 2.5vw, 1rem);
  padding: 0 10px;
}
.metrics-container {
  display: flex;
  justify-content: center;
  align-items: flex-start;
  gap: 20px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.canvas-group {
  text-align: center;
  min-width: 220px;
}
.canvas-group h3 {
  margin: 0 0 10px 0;
  color: #333;
  font-size: clamp(0.9rem, 3vw, 1.1rem);
}
.image-drop {
  width: 320px;
  height: 200px;
  max-width: 90vw;
  border: 2px dashed #888;
  border-radius: 6px;
  background-color: #fff;
  cursor: pointer;
  box-sizing: border-box;
  object-fit: contain;
}
.image-drop:hover {
  border-color: #555;
}
.metrics-controls {
  text-align: center;
  margin-bottom: 16px;
}
.metrics-controls button {
  padding: 12px 24px;
  font-size: clamp(1rem, 3vw, 1.1rem);
  background-color: #007bff;
  color: white;
  border: none;
  border-radius: 5px;
  cursor: pointer;
  min-height: 44px;
  touch-action: manipulation;
}
.metrics-controls button:hover {
  background-color: #0056b3;
}
.metrics-results {
  display: flex;
  justify-content: center;
  gap: 20px;
  flex-wrap: wrap;
  font-size: clamp(0.95rem, 2.5vw, 1.1rem);
  color: #333;
  text-align: center;
}
.metrics-results div {
  background: #fff;
  padding: 10px 16px;
  border-radius: 6px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.08);
}
#status {
  display: block;
  margin-top: 8px;
  color: #666;
  font-size: clamp(0.85rem, 2.5vw, 1rem);
}
#image-container {
  display: flex;
  flex-direction: row;
  justify-content: center;
  align-items: center;
  gap: 20px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.canvas-wrapper {
  text-align: center;
  flex: 1;
  min-width: 200px;
  max-width: 300px;
}
.canvas-wrapper h3 {
  margin: 0 0 10px 0;
  color: #333;
  font-size: clamp(0.9rem, 3vw, 1.1rem);
}
canvas {
  width: 100%;
  max-width: 300px;
  height: auto;
  object-fit: contain;
  border: 2px solid #333;
  box-sizing: border-box;
  cursor: pointer;
  background-color: white;
  touch-action: manipulation;
}
canvas:hover {
  border-color: #666;
}
.controls {
  text-align: center;
  margin-top: 20px;
  padding: 0 10px;
}
#image-container .hint {
  margin-top: 8px;
  color: #666;
  font-size: clamp(0.75rem, 2.5vw, 0.9rem);
}
#match-button {
  padding: 12px 24px;
  font-size: clamp(1rem, 3vw, 1.1rem);
  background-color: #007bff;
  color: white;
  border: none;
  border-radius: 5px;
  cursor: pointer;
  min-height: 44px;
  touch-action: manipulation;
}
#match-button:hover {
  background-color: #0056b3;
}
#match-button:disabled {
  background-color: #ccc;
  cursor: not-allowed;
}
#time {
  margin-top: 10px;
  color: #666;
  font-size: clamp(0.8rem, 2.5vw, 1rem);
}

#upload-area {
  display: flex;
  gap: 20px;
  justify-content: center;
  margin: 20px 0;
  flex-wrap: wrap;
}

.upload-box {
  width: 320px;
  max-width: 90vw;
  height: 200px;
  border: 2px dashed #888;
  border-radius: 6px;
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  position: relative;
  box-sizing: border-box;
  transition: border-color 0.2s ease;
}

.upload-box:hover {
  border-color: #555;
}

.upload-box.has-image {
  border-style: solid;
  border-color: #007bff;
}

.upload-box img {
  max-width: 100%;
  max-height: 100%;
  position: absolute;
  object-fit: contain;
}

.upload-label {
  color: #666;
  text-align: center;
  pointer-events: none;
  font-size: clamp(0.9rem, 2.5vw, 1rem);
}

#parameters {
  display: none;
  background: #fff;
  padding: 20px;
  margin: 20px auto;
  max-width: 800px;
  border-radius: 8px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.08);
}

#parameters.show {
  display: block;
}

#parameters label {
  display: block;
  margin-bottom: 5px;
  color: #333;
}

#parameters h3 {
  color: #333;
  margin: 20px 0 10px 0;
}

#parameters h3:first-of-type {
  margin-top: 0;
}

#parameters input[type="range"] {
  width: 100%;
  margin-bottom: 10px;
}

.param-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 15px;
}

.checkbox-inline-label {
  display: inline-block;
  margin-left: 8px;
  color: #333;
}

#stats {
  text-align: center;
  margin: 20px 0;
  font-family: monospace;
  color: #333;
}

.stat-row {
  margin: 5px 0;
}

.legend {
  text-align: center;
  margin: 10px 0;
  font-size: 14px;
  color: #333;
}

.legend span {
  margin: 0 10px;
  padding: 2px 6px;
  border-radius: 3px;
  display: inline-block;
  color: #333;
  background: #eee;
}

.badge {
  color: #333;
  background: #eef1f6;
}

.badge--excellent {
  background: #b8f5b8;
}

.badge--good {
  background: #fff7b3;
}

.badge--fair {
  background: #ffd4a3;
}

.badge--poor {
  background: #ffb3b3;
  color: #8c0000;
}

#result-area {
  text-align: center;
  margin: 20px auto;
}

#result-canvas {
  display: none;
  width: 100%;
  max-width: min(900px, 90vw);
  height: auto;
  border: 2px solid #333;
  background: #fff;
}

#result-canvas.visible {
  display: inline-block;
}

/* Mobile-specific styles */
@media (max-width: 768px) {
  body {
    padding: 5px;
  }
  #image-container {
    flex-direction: column;
    gap: 15px;
  }
  .canvas-wrapper {
    width: 100%;
    max-width: 90vw;
  }
  canvas {
    max-width: 90vw;
  }
  .header {
    margin-bottom: 15px;
  }
  .instructions {
    margin-bottom: 15px;
    font-size: 0.9rem;
  }
  #match-button {
    width: 90%;
    max-width: 300px;
  }
}

/* Very small screens */
@media (max-width: 480px) {
  .header h1 {
    font-size: 1.3rem;
  }
  .header p {
    font-size: 0.8rem;
  }
  .canvas-wrapper h3 {
    font-size: 1rem;
  }
  #image-container {
    gap: 10px;
  }
}

/* Legacy styles for backward compatibility */
#form {
  width: 300px;
  margin: 10px;
}

#video {
  position: absolute;
}

#canvas-webcam {
  border: 1px dashed black;
  vertical-align: center;
  width: 640px;
  height: auto;
  left: 0px;
  top: 0px;
  max-width: none;
  cursor: default;
}

#canvas-perlin {
  border: 1px solid black;
}

#canvas-container {
  position: relative;
  display: inline-block;
}

#canvas-seam{
  border: 1px solid black;
  max-width: 90vw;
  max-height: 80vh;
  width: auto;
  height: auto;
  object-fit: contain;
  display: block;
}

#seam-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 10;
}

/* Button styles - unified across all examples (excluding copy buttons) */
button:not(.copy-button), #toggle-button, #align-button, #remove-button, #webcamToggleButton, #toggleButton {
  padding: 12px 24px;
  font-size: clamp(1rem, 3vw, 1.1rem);
  background-color: #007bff;
  color: white;
  border: none;
  border-radius: 5px;
  cursor: pointer;
  min-height: 44px;
  touch-action: manipulation;
  margin: 5px;
}

button:not(.copy-button):hover, #toggle-button:hover, #align-button:hover, #remove-button:hover, #webcamToggleButton:hover, #toggleButton:hover {
  background-color: #0056b3;
}

button:not(.copy-button):disabled, #toggle-button:disabled, #align-button:disabled, #remove-button:disabled, #webcamToggleButton:disabled, #toggleButton:disabled {
  background-color: #ccc;
  cursor: not-allowed;
}

#toggle-button {
  margin: 20px;
}

input {
  font-size: 20px;
  width: 150px;
}

/* Do not force width on checkboxes/radios */
input[type="checkbox"],
input[type="radio"] {
  width: auto;
}

#validation-message {
  color: #bf616a;
}

#color {
  width: 158px;
}

/* Examples index page styles */
.examples-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 20px;
  max-width: 1200px;
  margin: 0 auto;
  padding: 20px;
}

.example-card {
  background: white;
  border: 2px solid #333;
  border-radius: 8px;
  padding: 20px;
  transition: all 0.3s ease;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.example-card h3 {
  margin: 0 0 10px 0;
  color: #333;
  font-size: 1.2rem;
}

.example-card h3 a {
  color: #333;
  text-decoration: none;
}

.example-card h3 a:hover {
  color: #007bff;
}

.example-card p {
  margin: 0;
  color: #666;
  line-height: 1.4;
  font-size: 0.95rem;
}

/* Mobile responsive */
@media (max-width: 768px) {
  .examples-grid {
    grid-template-columns: 1fr;
    gap: 15px;
    padding: 15px;
  }

  .example-card {
    padding: 15px;
  }
}
