/* Photos from the partner's own cloud (cloud.js): the way in on this device's page, and the sheet they're picked in */

/* the way in: under this device's words, as the folder's way, but the partner's own photos are a first way in, so it
   reads as a button in the partner's colour; above the page's pick-anything layer (#drop::after) */
.ways-here > .ways-cloud {
  position: relative;
}
.ways-cloud {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  min-height: 44px;
  margin-top: 4px;
  padding: 2px 18px 2px 14px;
  border: 1.5px solid color-mix(in srgb, var(--accent) 45%, transparent);
  border-radius: 999px;
  background: rgb(255 255 255 / 0.78);
  color: var(--text);
  font: inherit;
  font-weight: 500;
  line-height: 1.25;
  text-align: left;
  text-wrap: balance;
  cursor: pointer;
  transition:
    background 0.2s,
    border-color 0.2s,
    transform 0.25s var(--ease);
}
.ways-cloud svg {
  flex: none;
}
.ways-cloud svg {
  width: 22px;
  height: 22px;
  fill: color-mix(in srgb, var(--accent) 16%, transparent);
  stroke: var(--accent);
  stroke-width: 1.6;
  stroke-linejoin: round;
}
.ways-cloud:hover,
.ways-cloud:focus-visible {
  border-color: var(--accent);
  background: #fff;
}
.ways-cloud:hover svg {
  animation: cloud-drift 1.6s ease-in-out infinite;
}
.ways-cloud:active {
  transform: scale(0.97);
}
@keyframes cloud-drift {
  50% {
    transform: translate(2px, -2px);
  }
}
/* a phone held sideways lays its page in a row: the cloud's way goes under the device's own */
@media (orientation: landscape) {
  .ways.on-phone .ways-here:has(> .ways-cloud:not([hidden])) {
    grid-auto-flow: row;
  }
}

/* ---- the sheet: the whole screen on a phone, a big card over the dimmed page on a wider one */
.cloud {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  max-width: none;
  max-height: none;
  margin: 0;
  padding: 0;
  border: 0;
  display: grid;
  place-items: center;
  background: rgb(30 26 22 / 0.42);
  color: var(--text);
  font-family: var(--ui-font);
}
/* it rises in by CSS alone: WebKit holds back a cross-origin frame's animation frames (a partner's page, a web view), so
   a class set on the next frame could leave it unseen until the next tap */
.cloud[open] {
  animation: cloud-dim 0.3s;
}
.cloud[open] .cloud-card {
  animation: cloud-rise 0.38s var(--ease);
}
@keyframes cloud-dim {
  from {
    background: rgb(30 26 22 / 0);
  }
}
@keyframes cloud-rise {
  from {
    transform: translateY(24px);
    opacity: 0;
  }
}
.cloud:not([open]) {
  display: none;
}
.cloud::backdrop {
  background: none;
}
.cloud-card {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  width: 100%;
  height: 100%;
  background: var(--sheet-paper);
}
@media (min-width: 700px) and (min-height: 560px) {
  .cloud-card {
    width: min(920px, 100% - 48px);
    height: min(760px, 100% - 48px);
    border-radius: max(var(--radius), 20px);
    box-shadow: 0 30px 80px -24px rgb(30 20 10 / 0.55);
    overflow: hidden;
  }
}

.cloud-head {
  display: grid;
  grid-template-columns: minmax(44px, auto) 1fr 44px;
  align-items: center;
  gap: 8px;
  padding: max(10px, env(safe-area-inset-top)) 12px 10px;
  border-bottom: 1px solid var(--line);
}
.cloud-title {
  grid-column: 2;
  margin: 0;
  overflow: hidden;
  font-size: 17px;
  font-weight: 600;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.cloud-back,
.cloud-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  min-height: 44px;
  padding: 0 8px;
  border: 0;
  border-radius: 999px;
  background: none;
  color: var(--text);
  font: inherit;
  cursor: pointer;
}
.cloud-back {
  grid-column: 1;
  justify-self: start;
  gap: 2px;
  padding-right: 12px;
}
.cloud-close {
  grid-column: 3;
}
.cloud-back:hover,
.cloud-close:hover {
  background: rgb(36 34 31 / 0.06);
}
.cloud-back svg,
.cloud-close svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.cloud-body {
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 16px;
  display: grid;
  align-content: start;
  justify-items: center;
  gap: 14px;
}
.cloud-line {
  margin: 12vh 0 0;
  max-width: 28ch;
  color: var(--quiet);
  font-size: 16px;
  line-height: 1.4;
  text-align: center;
  text-wrap: balance;
}

/* the albums: each a little stack of prints, its cover on top */
.cloud-albums {
  grid-template-columns: repeat(auto-fill, minmax(min(170px, 42vw), 1fr));
  justify-items: stretch;
  gap: 22px 16px;
  padding: 20px;
}
.cloud-album {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.cloud-cover {
  position: relative;
  display: block;
  flex: none;
  aspect-ratio: 1;
  margin-bottom: 8px;
  border-radius: 10px;
  background: #e9e3d9;
  box-shadow:
    0 1px 2px rgb(40 30 20 / 0.18),
    0 6px 14px -8px rgb(40 30 20 / 0.4);
  transition: transform 0.3s var(--ease);
}
/* the prints under the cover, peeking out at the top */
.cloud-cover::before,
.cloud-cover::after {
  content: '';
  position: absolute;
  inset: 0;
  z-index: -1;
  border-radius: inherit;
  background: #f3eee6;
  box-shadow: 0 1px 2px rgb(40 30 20 / 0.16);
  transition: transform 0.3s var(--ease);
}
.cloud-cover::before {
  transform: translate(-3px, -5px) rotate(-3deg);
}
.cloud-cover::after {
  transform: translate(4px, -4px) rotate(2.5deg);
  background: #ebe5db;
}
.cloud-album {
  isolation: isolate;
}
.cloud-album:hover .cloud-cover,
.cloud-album:focus-visible .cloud-cover {
  transform: translateY(-3px) rotate(-1deg);
}
.cloud-album:hover .cloud-cover::before {
  transform: translate(-7px, -7px) rotate(-6deg);
}
.cloud-album:hover .cloud-cover::after {
  transform: translate(8px, -6px) rotate(5deg);
}
.cloud-album:focus-visible {
  outline: none;
}
.cloud-album:focus-visible .cloud-album-title {
  text-decoration: underline 2px var(--accent);
  text-underline-offset: 3px;
}
.cloud-cover img {
  width: 100%;
  height: 100%;
  border-radius: inherit;
  object-fit: cover;
}
.cloud-album-title {
  overflow: hidden;
  font-weight: 600;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.cloud-album-count {
  min-height: 1.3em;
  color: var(--quiet);
  font-size: 14px;
}
.cloud-album.has-picked .cloud-album-count {
  color: var(--text);
}

/* an album's photos: square tiles, edge to edge as in a phone's own photos */
.cloud-photos {
  grid-template-columns: repeat(auto-fill, minmax(min(124px, 31vw), 1fr));
  justify-items: stretch;
  /* each tile as tall as it's wide (stretched, a row would take its height from the others) */
  align-items: start;
  gap: 3px;
  padding: 3px;
}
.cloud-photo {
  position: relative;
  aspect-ratio: 1;
  padding: 0;
  border: 0;
  background: #ebe5db;
  cursor: pointer;
}
/* (the tile clips nothing itself: overflow would take away its height's floor, aspect-ratio's) */
.cloud-photo img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  transition:
    opacity 0.3s,
    transform 0.3s var(--ease);
}
.cloud-photo img.is-in:not(.is-unread) {
  opacity: 1;
}
/* picked: the photo steps back inside a ring of the partner's colour, and a tick pops in */
.cloud-photo[aria-pressed='true'] img {
  transform: scale(0.86);
  border-radius: 6px;
}
.cloud-photo::after {
  content: '';
  position: absolute;
  top: 7px;
  right: 7px;
  width: 22px;
  height: 22px;
  border: 1.5px solid #fff;
  border-radius: 50%;
  background: rgb(0 0 0 / 0.14);
  box-shadow: 0 1px 3px rgb(0 0 0 / 0.3);
  transition: transform 0.35s cubic-bezier(0.3, 1.6, 0.5, 1);
}
.cloud-photo[aria-pressed='true'] {
  background: color-mix(in srgb, var(--accent) 22%, #f3eee6);
}
.cloud-photo[aria-pressed='true']::after {
  border-color: var(--accent);
  background: var(--accent)
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M6.5 12.5l3.5 3.5 7.5-8' fill='none' stroke='white' stroke-width='2.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E")
    center / 16px no-repeat;
  transform: scale(1.15);
  animation: cloud-tick 0.35s cubic-bezier(0.3, 1.6, 0.5, 1);
}
@keyframes cloud-tick {
  from {
    transform: scale(0.4);
  }
}
/* a photo whose little picture didn't come: a quiet picture-with-no-picture in its middle (its label says so too) */
.cloud-photo.is-unseen::before {
  content: '';
  position: absolute;
  inset: 0;
  margin: auto;
  width: 30%;
  height: 30%;
  background: var(--quiet);
  opacity: 0.55;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='3.5' y='5' width='17' height='14' rx='2.5'/%3E%3Cpath d='M3.5 16l5-5 4 4M14 13.5l2-2 4.5 4.5M3 3l18 18'/%3E%3C/svg%3E")
    center / contain no-repeat;
}
.cloud-photo:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: -3px;
}

/* what waits for the partner's answer: soft tiles breathing */
.is-placeholder {
  display: block;
  aspect-ratio: 1;
  border-radius: 10px;
  background: #ebe5db;
  animation: cloud-wait 1.4s ease-in-out infinite alternate;
}
.cloud-photo.is-placeholder {
  border-radius: 0;
}
@keyframes cloud-wait {
  to {
    opacity: 0.45;
  }
}

/* the foot: what's said, the whole album's switch and the button, a thin bar along the top while the photos come */
.cloud-foot {
  position: relative;
  display: grid;
  gap: 8px;
  padding: 12px 16px max(12px, env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  background: var(--sheet-paper);
}
.cloud-said {
  margin: 0;
  font-size: 15px;
  line-height: 1.35;
  text-align: center;
}
.cloud-said:empty {
  display: none;
}
.cloud-said .chip {
  margin-top: 6px;
  font: inherit;
  cursor: pointer;
}
.cloud-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
}
.cloud-actions .chip {
  min-height: 46px;
  font: inherit;
  font-weight: 500;
  cursor: pointer;
}
.cloud-add {
  flex: 1 1 auto;
  max-width: 420px;
  justify-content: center;
  font-variant-numeric: tabular-nums;
  transition: opacity 0.2s;
}
.cloud-add:disabled {
  opacity: 0.45;
  cursor: default;
}
.cloud.is-fetching .cloud-add {
  opacity: 1;
}
.cloud.is-fetching .cloud-all {
  display: none;
}
.cloud-bar {
  position: absolute;
  top: -1px;
  left: 0;
  height: 3px;
  width: 100%;
  background: var(--accent);
  transform: scaleX(var(--done, 0));
  transform-origin: left;
  transition: transform 0.3s var(--ease);
}

@media (prefers-reduced-motion: reduce) {
  .cloud[open],
  .cloud[open] .cloud-card,
  .cloud-photo img,
  .cloud-photo::after,
  .cloud-cover,
  .cloud-cover::before,
  .cloud-cover::after {
    transition: none;
    animation: none;
  }
  .ways-cloud:hover svg,
  .is-placeholder {
    animation: none;
  }
}
