/* Palettes — the member moodboard index and canvas.
   The canvas positions swatches absolutely from stored coordinates; the drag
   layer added later moves them via `transform`, so nothing here may set
   `top`/`left` on .palette-object. */

/* ---------- Index ---------- */

.palettes-main {
  min-width: 0;
}

.palettes-title {
  margin-bottom: var(--space-5);
}

.palettes-intro {
  color: var(--color-gray-40, #6b6b6d);
  font-size: var(--font-size-3);
  margin-top: var(--space-2);
}

.palettes-limit {
  background: var(--color-secondary-tint);
  border-radius: var(--radius-2);
  font-size: var(--font-size-3);
  margin-bottom: var(--space-5);
  padding: var(--space-3) var(--space-4);
}

.palettes-empty {
  color: var(--color-gray-40, #6b6b6d);
  font-size: var(--font-size-3);
  margin-top: var(--space-5);
}

.palette-grid {
  display: grid;
  gap: var(--space-5);
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
}

.palette-card-wrapper {
  position: relative;
}

.palette-card {
  border: 1px solid var(--color-gray-4);
  border-radius: var(--radius-2);
  color: inherit;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  text-decoration: none;
  transition: border-color 150ms ease;
}

.palette-card:hover {
  border-color: var(--color-black);
}

.palette-card-preview {
  aspect-ratio: 4 / 3;
  background: var(--color-gray-1);
  display: grid;
  grid-template-columns: 1fr 1fr;
  position: relative;
}

.palette-card-swatch {
  height: 100%;
  object-fit: cover;
  width: 100%;
}

/* A lone swatch fills the tile rather than leaving three empty cells. */
.palette-card-swatch:only-child {
  grid-column: span 2;
}

.palette-card-more,
.palette-card-empty {
  align-items: center;
  color: var(--color-gray-40, #6b6b6d);
  display: flex;
  font-size: var(--font-size-2);
  justify-content: center;
}

.palette-card-more {
  background: rgba(255, 255, 255, 0.9);
  border-radius: var(--radius-1);
  bottom: var(--space-2);
  padding: var(--space-1) var(--space-2);
  position: absolute;
  right: var(--space-2);
}

.palette-card-empty {
  grid-column: span 2;
}

.palette-card-title {
  font-size: var(--font-size-3);
  padding: var(--space-3);
}

.palette-card-new {
  align-items: center;
  aspect-ratio: 4 / 3;
  border-style: dashed;
  gap: var(--space-2);
  justify-content: center;
}

.palette-card-new-mark {
  font-size: var(--font-size-7);
  line-height: 1;
}

.palette-card-delete-form {
  position: absolute;
  right: var(--space-2);
  top: var(--space-2);
}

.palette-card-delete {
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid var(--color-gray-4);
  border-radius: var(--radius-1);
  cursor: pointer;
  font-size: var(--font-size-2);
  opacity: 0;
  padding: var(--space-1) var(--space-2);
  transition: opacity 150ms ease;
}

.palette-card-wrapper:hover .palette-card-delete,
.palette-card-delete:focus-visible {
  opacity: 1;
}

/* ---------- Canvas ---------- */

.palette-toolbar {
  align-items: flex-end;
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-4);
  justify-content: space-between;
  margin-bottom: var(--space-4);
}

.palette-description {
  color: var(--color-gray-40, #6b6b6d);
  font-size: var(--font-size-3);
  margin-top: var(--space-2);
}

.palette-toolbar-actions {
  align-items: center;
  display: flex;
  gap: var(--space-4);
}

.palette-count {
  font-size: var(--font-size-3);
}

.palette-wrapper {
  background-color: var(--color-gray-1);
  /* The grid is the canvas backdrop; .no-grid is the saved "off" state. */
  background-image:
    linear-gradient(to right, var(--color-gray-4) 1px, transparent 1px),
    linear-gradient(to bottom, var(--color-gray-4) 1px, transparent 1px);
  background-size: 32px 32px;
  border: 1px solid var(--color-gray-4);
  overflow: hidden;
  position: relative;
}

.palette-wrapper.no-grid {
  background-image: none;
}

.palette-space {
  height: 864px;
  position: relative;
  width: 100%;
}

.palette-object {
  background-position: center;
  background-repeat: no-repeat;
  background-size: cover;
  left: 0;
  position: absolute;
  top: 0;
  touch-action: none;
}

/* A tile is a repeating pattern — it reads correctly only when it repeats. */
.palette-object.tile {
  background-repeat: repeat;
  background-size: auto;
}

.palette-object.legend {
  background-size: contain;
}

.palette-object-overlay {
  display: flex;
  flex-direction: column;
  height: 100%;
  justify-content: space-between;
  opacity: 0;
  transition: opacity 150ms ease;
}

.palette-object:hover .palette-object-overlay,
.palette-object:focus-within .palette-object-overlay {
  background: rgba(255, 255, 255, 0.92);
  opacity: 1;
}

.palette-object-tools {
  display: flex;
  gap: var(--space-2);
  padding: var(--space-3);
}

.palette-tool {
  background: none;
  border: none;
  color: var(--color-black);
  cursor: pointer;
  /* Sit at content width — links inherit a full-width rule further up, which
     otherwise makes flex spread these across the swatch. */
  flex: 0 0 auto;
  font-size: var(--font-size-2);
  padding: 0;
  text-decoration: underline;
  width: auto;
}

.palette-tool-form {
  display: inline;
}

.palette-object-content {
  padding: var(--space-3);
}

.palette-swatch-title {
  font-size: var(--font-size-3);
  font-weight: normal;
}

.palette-swatch-title span {
  display: block;
}

.palette-swatch-brand {
  font-size: var(--font-size-2);
  text-transform: uppercase;
}

.palette-swatch-meta,
.palette-swatch-price {
  font-size: var(--font-size-2);
  margin-top: var(--space-2);
}

/* Resize affordance. Inert until the drag layer binds to it. */
.palette-object-handle {
  bottom: 0;
  cursor: se-resize;
  height: 16px;
  position: absolute;
  right: 0;
  width: 16px;
}

/* The canvas has a fixed working size and no small-screen equivalent. */
@media (max-width: 900px) {
  .palette-wrapper {
    display: none;
  }

  .palette-show-page .palette-toolbar-actions {
    display: none;
  }

  .palette-show-page .section-inner::after {
    content: "Palettes need a larger screen to edit.";
    display: block;
    font-size: var(--font-size-3);
    margin-top: var(--space-5);
  }
}
