/* My Palette's Edit menu (userPalette.ts), in the reusable dialog. */

/* While picking, the dialog keeps one height, so saving, removing or a
   message moves nothing: the middle scrolls, and the foot stays at the bottom. Asking to remove is a
   step of its own, as tall as its question. */
#reusableModal .reusable-modal-content[data-palette-menu] {
  height: min(560px, 85dvh);
  max-height: 85dvh;
}

#reusableModal .reusable-modal-content[data-palette-menu][data-confirming] {
  height: auto;
}

.palette-menu {
  text-align: left;
}

/* Room under the last row of fills, so the foot's line never cuts against them. */
.palette-menu-picking,
.palette-menu-confirm {
  flex: 1 1 auto;
  min-height: 0;
  padding-bottom: 16px;
  overflow: hidden auto;
  --focus-ring-offset: -2px;
}

.palette-menu-about {
  color: var(--ink-6);
  font-size: 0.9em;
  line-height: 1.4;
}

.palette-menu.is-confirming .palette-menu-about {
  display: none;
}

.palette-menu h4 {
  margin: 12px 0 8px;
}

.palette-menu-count {
  color: var(--ink-3);
  font-size: 0.85em;
  font-weight: normal;
}

.palette-menu-selected {
  display: flex;
  align-items: center;
  gap: 12px;
}

.palette-menu-selected > button {
  flex: 1 1 auto;
  margin: 0;
}

.palette-menu-note {
  flex: 1 1 auto;
  color: var(--ink-6);
}

.palette-menu-tile {
  display: block;
  box-sizing: border-box;
  width: 100%;
  aspect-ratio: 1;
  overflow: hidden;
  border: 1px solid var(--line-4);
  border-radius: 6px;
}

.palette-menu-selected .palette-menu-tile {
  flex: none;
  width: 64px;
}

.palette-menu-tile svg {
  display: block;
  width: 100%;
  height: 100%;
}

.palette-menu-saved-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
}

.palette-menu-clear {
  position: relative;
  padding: 0;
  border: none;
  background: none;
  color: var(--ink-6);
  font: inherit;
  text-decoration: underline;
  cursor: pointer;
}

.palette-menu-list,
.palette-menu-doomed {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(48px, 1fr));
  gap: 8px;
}

.palette-menu-pick {
  position: relative;
  display: block;
  width: 100%;
  padding: 0;
  border: none;
  border-radius: 6px;
  background: none;
  cursor: pointer;
}

/* A ring in two colors and a badge on its own disc, so a pick shows on black, white or a busy fill. */
.palette-menu-pick[aria-pressed="true"]::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 6px;
  box-shadow: inset 0 0 0 3px var(--ui-accent), inset 0 0 0 5px var(--surface);
}

.palette-menu-pick[aria-pressed="true"]::after {
  content: "";
  position: absolute;
  top: -5px;
  right: -5px;
  box-sizing: border-box;
  width: 22px;
  height: 22px;
  border: 2px solid var(--surface);
  border-radius: 50%;
  background: var(--ui-accent) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M2.5 6.5l2.5 2.5 4.5-5' fill='none' stroke='white' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / 12px no-repeat;
}

/* A line on top, so saved fills scrolling under it read as going on. */
.palette-menu-foot {
  flex: none;
  margin: 0 calc(-1 * var(--sheet-inline-padding)) calc(-1 * var(--sheet-inline-padding));
  padding: 12px var(--sheet-inline-padding) var(--sheet-inline-padding);
  border-top: 1px solid var(--line-2);
  background: var(--surface);
}

/* Its line is kept whether or not there is something to say, so a message moves nothing. */
.palette-menu-status {
  min-height: 1.4em;
  color: var(--ink-6);
  line-height: 1.4;
}

.palette-menu-retry {
  width: 100%;
  min-height: 44px;
  margin: 0 0 8px;
}

.palette-menu-actions {
  display: flex;
  gap: 8px;
}

.palette-menu-actions button {
  flex: 1 1 0;
  min-height: 44px;
  margin: 0;
}

.palette-menu:not(.is-confirming) :is(.palette-menu-cancel, .palette-menu-remove-now),
.palette-menu.is-confirming :is(.palette-menu-remove, .palette-menu-done) {
  display: none;
}

.palette-menu-remove-now {
  background: var(--danger-dark);
  color: var(--surface);
}

@media (max-width: 768px), (max-height: 500px) {
  .palette-menu-foot {
    margin: 0 calc(-1 * var(--sheet-inline-padding)) calc(-1 * var(--sheet-inline-padding) - env(safe-area-inset-bottom, 0px));
    padding: 8px var(--sheet-inline-padding) calc(var(--sheet-inline-padding) + env(safe-area-inset-bottom, 0px));
  }
}

/* A whole palette needs more room than a confirmation does. */
@media (min-width: 769px) and (min-height: 501px) {
  #reusableModal .reusable-modal-content[data-palette-menu] {
    width: 520px;
  }
}

/* How far the tap area reaches past what it draws (the `tap-area` rule in tokens.css). */
.palette-menu-clear { --tap-y: -14px; --tap-x: -10px; }
