:root {
  --swatch-gap: 10px;
}

.palette-maker-wrap {
  font-family: sans-serif;
  margin: 0;
  padding: 0;
}

.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 1em;
  align-items: flex-start; /* prevents button drop */
  margin-bottom: 2em;
}

.input-controls {
  display: flex;
  flex-direction: column;
  gap: 1em;
  flex: 1 1 300px;
  min-width: 200px;
}

.input-group {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5em;
}

.input-group label {
  flex: 0 0 140px; /* fixed width label */
  font-weight: bold;
  align-self: center;
}

.input-group input,
.input-group select {
  flex: 1 1 auto;
  min-width: 0;
}

.generate-button-container {
  flex: 0 0 auto;
  align-self: stretch;
  display: flex;
  align-items: center;
  justify-content: center;
}

.generate-button-container button {
  width: 100%;
  height: 100%;
  padding: 0.8em 1.2em;
  white-space: nowrap;
  text-align: center;
  font-weight: bold;
  border-radius: 4px;
  cursor: pointer;
}

/* Palette Swatches */
.palette-grid {
  display: flex;
  flex-direction: column;
  gap: var(--swatch-gap);
  margin-bottom: 2em;
}

.palette-subgrid {
  display: flex;
  gap: var(--swatch-gap);
  flex-wrap: wrap;
  justify-content: space-between;
}

.swatch-card {
  flex: 1 1 0;
  height: 120px;
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  color: white;
  padding: 0.8em;
  position: relative;
  overflow: hidden;
  min-width: 0;
}

.swatch-footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: flex-end;
  font-size: 14px;
  font-weight: bold;
  gap: 0.25em;
}

.swatch-footer .hex {
  display: flex;
  align-items: center;
  gap: 6px;
}

.swatch-footer .copy-icon {
  cursor: pointer;
  font-size: 16px;
  opacity: 0.8;
  transition: opacity 0.2s ease;
}

.copy-icon {
  transition: transform 0.2s ease, opacity 0.2s ease;
}

.copy-icon.clicked {
  transform: scale(1.2);
  opacity: 1;
}

.swatch-footer .copy-icon:hover {
  opacity: 1;
}

/* Live Preview */
.preview {
  margin-top: 2em;
  border-top: 1px solid #ccc;
  padding-top: 1em;
}

.preview-box {
  padding: 2em;
  border-radius: 6px;
  background: #f0f0f0;
  margin-bottom: 2em;
}

.preview-box h1 {
  margin-top: 0;
}

.preview-button {
  padding: 0.5em 1em;
  border: none;
  border-radius: 4px;
  font-weight: bold;
  cursor: pointer;
}

.export {
  margin-top: 2em;
}

textarea#json-output {
  width: 100%;
  height: 150px;
  font-family: monospace;
  margin-bottom: 1em;
}

/* Layouts */
.layout-row {
  display: flex;
  flex-wrap: wrap;
  gap: 2em;
}

.preview,
.palette-col {
  flex: 1 1 45%;
  min-width: 0;
  max-width: 100%;
}

.preview-card {
  background: var(--bg);
  color: var(--text);
  border-radius: 6px;
  padding: 1em;
  margin-top: 1em;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.1);
}

.preview-card h4 {
  margin: 0 0 0.5em;
}

@media (max-width: 720px) {
  .controls {
    flex-direction: column;
    align-items: stretch;
  }

  .input-group {
    flex-direction: column;
    align-items: stretch;
  }

  .input-group label {
    flex: none;
    width: auto;
  }

  .generate-button-container {
    width: 100%;
    min-width: 0;
    height: auto;
  }

  .generate-button-container button {
    width: 100%;
  }

  .swatch-footer {
    flex-direction: column;
    align-items: flex-start;
    font-size: 12px;
  }

  .swatch-footer .hex {
    white-space: nowrap;
  }

  .swatch-card {
    padding: 0.6em;
  }

  #dark-row .swatch-card {
    flex: 1 1 calc(50% - var(--swatch-gap) / 2);
    max-width: calc(50% - var(--swatch-gap) / 2);
  }
}

