/* The "my pictures" pages - holypuzzle.com's /my-jigsaw-puzzle and puzzlefun.net's /my-puzzle
   (templates/my-pictures/fragments.html): the preview's Save button, the user's saved pictures
   below the picker, and the toast. Loaded after the site's puzzle.css and my-pictures/picker.css,
   whose color tokens and button styles it builds on. */

/* The preview's "Save to My pictures" button: outlined in the accent color until saved */
#save {
  display: inline-flex; align-items: center; gap: 6px;
  border-color: var(--accent); color: var(--accent); font-weight: 600;
}
#save svg { width: 15px; height: 15px; }
#save:hover:not(:disabled) { background: var(--accent-soft); }
#save:disabled { cursor: default; opacity: .7; }
#save.done { opacity: 1; border-color: var(--line); color: var(--muted); background: transparent; }
#save.done svg { display: none; }
#save.done .label::before { content: "\2713\FE0E  "; } /* ✓ as text, not an emoji */
#mine { width: min(1100px, 100%); margin-top: 28px; }
#mine[hidden] { display: none; }
.mine-head {
  display: flex; align-items: baseline; justify-content: space-between; gap: 12px;
  margin: 0 0 12px; padding-bottom: 8px; border-bottom: 1px solid var(--line);
}
.mine-head h2 { margin: 0; font-size: 18px; letter-spacing: -0.01em; }
#mine-count { color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }

#toast {
  position: fixed; left: 50%; bottom: 24px; z-index: 200;
  max-width: calc(100% - 32px); text-align: center;
  transform: translate(-50%, 16px); opacity: 0; pointer-events: none;
  background: var(--text); color: var(--bg);
  font-size: 14px; font-weight: 600;
  padding: 9px 18px; border-radius: 999px; box-shadow: var(--shadow);
  transition: opacity .2s, transform .2s;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }

.message {
  max-width: 480px; margin: 24px auto; padding: 28px 24px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 16px;
  text-align: center; color: var(--muted);
}
.message[hidden] { display: none; }
.message svg { width: 40px; height: 40px; color: var(--accent); display: block; margin: 0 auto 10px; }
.message strong { display: block; color: var(--text); font-size: 17px; margin-bottom: 4px; }

/* Masonry: CSS columns, so a newly saved picture can simply be prepended */
.masonry { columns: 3; column-gap: 14px; }
.card {
  display: block; position: relative; break-inside: avoid;
  margin-bottom: 14px; border-radius: 12px; overflow: hidden;
  background: var(--line); box-shadow: var(--shadow);
  transform: translateZ(0); /* keeps rounded corners clipping during hover scale */
}
.card .play { display: block; border-radius: inherit; }
.card .play:focus-visible { outline: 3px solid var(--accent); outline-offset: -3px; }
.card img {
  display: block; width: 100%; height: auto;
  transition: transform .35s ease, opacity .4s; opacity: 0;
}
.card img.loaded { opacity: 1; }
.card:hover img, .card:focus-within img { transform: scale(1.04); }
.card .date {
  position: absolute; left: 10px; top: 10px;
  background: rgba(0, 0, 0, .55); color: #fff;
  font-size: 12px; font-weight: 600;
  padding: 3px 10px; border-radius: 999px;
}
.card .date:empty { display: none; } /* still saving */
/* Always-visible actions along the bottom: "Play jigsaw" on the left (a label only - clicks pass
   through to the card's link), Delete on the right. They wrap onto two lines on narrow cards. */
.card .actions {
  position: absolute; left: 10px; right: 10px; bottom: 10px;
  display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 6px;
  pointer-events: none;
}
.card .play-label, .card .delete {
  padding: 6px 14px; border-radius: 999px; white-space: nowrap;
  font: inherit; font-size: 13px; font-weight: 600; line-height: 1.4;
  box-shadow: 0 2px 8px rgba(0, 0, 0, .25);
}
.card .play-label {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--accent); color: #fff;
}
.card .play-label svg { width: 12px; height: 12px; }
.card:has(.play:hover) .play-label { filter: brightness(1.1); }
.card .delete {
  pointer-events: auto; margin-left: auto;
  border: 0; cursor: pointer;
  background: rgba(0, 0, 0, .6); color: #fff;
  transition: background .15s;
}
.card .delete:hover { background: #dc2626; border-color: transparent; }
.card .delete:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
/* Picture being saved: the local file, dimmed, with a spinner and no link or delete yet */
.card.uploading { pointer-events: none; }
.card.uploading img { filter: brightness(.6) saturate(.7); }
.card.uploading::before {
  content: ""; position: absolute; left: 50%; top: 50%; z-index: 1;
  width: 34px; height: 34px; margin: -17px 0 0 -17px;
  border: 3px solid rgba(255, 255, 255, .35); border-top-color: #fff; border-radius: 50%;
  animation: spin .8s linear infinite;
}
.card.uploading::after {
  content: attr(data-saving); /* "Saving…", in the page's language - set by my-pictures.ts */
  position: absolute; left: 50%; bottom: 10px; transform: translateX(-50%);
  background: rgba(0, 0, 0, .65); color: #fff;
  font-size: 13px; font-weight: 600;
  padding: 6px 14px; border-radius: 999px;
}
@keyframes spin { to { transform: rotate(360deg); } }
/* Just saved (or already there): a brief ring */
.card.added { animation: added 1.6s ease-out; }
@keyframes added {
  0%, 40% { box-shadow: 0 0 0 4px var(--accent), var(--shadow); }
  100% { box-shadow: 0 0 0 4px transparent, var(--shadow); }
}
.card.deleting { opacity: .45; pointer-events: none; transition: opacity .2s; }

@media (max-width: 800px) { .masonry { columns: 2; } }
@media (max-width: 600px) {
  .masonry { column-gap: 8px; }
  .card { margin-bottom: 8px; border-radius: 8px; }
  .card .date { left: 6px; top: 6px; padding: 2px 8px; font-size: 11px; }
  .card .actions { left: 6px; right: 6px; bottom: 6px; gap: 4px; }
  .card .play-label, .card .delete { padding: 4px 10px; font-size: 12px; }
}
