/* Task 16: the upload panel, its "Stop adding photos?" question and the
   visitor name prompt (all one dark sheet: a bottom sheet on a phone, a
   centred card from 600px). The rest (the picker's input, the reload hint,
   the name field) is in upload-extras.css. Reuses app.css's tokens and
   .title, .btn, .btn-main and .dark. No inline styles: --progress is the
   only runtime value (upload-sheet.js, via el.style.setProperty). */

/* ---------- the sheet ---------- */

.upload-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  background: rgba(0, 0, 0, 0.62);
}

.upload-sheet {
  width: 100%;
  max-width: 520px;
  max-height: 92dvh;
  overflow-y: auto;
  overscroll-behavior: contain;
  /* No bottom padding of its own: the sticky buttons carry it (below). */
  padding: 24px calc(20px + env(safe-area-inset-right, 0px)) 0 calc(20px + env(safe-area-inset-left, 0px));
  /* A control focused further up is scrolled to above the sticky buttons, never under them. */
  scroll-padding-bottom: calc(112px + env(safe-area-inset-bottom, 0px));
  border-radius: 24px 24px 0 0;
  /* .dark gives it the night ground and moon text; a hairline and a lift
     keep it apart from the dark album under the backdrop. */
  box-shadow: inset 0 1px 0 var(--night-line), 0 -12px 34px rgba(0, 0, 0, 0.5);
}

@media (min-width: 600px) {
  .upload-backdrop {
    align-items: center;
    padding: 24px;
  }

  .upload-sheet {
    padding: 28px 28px 0;
    border-radius: var(--radius-card);
    box-shadow: inset 0 0 0 1px var(--night-line), 0 24px 60px rgba(0, 0, 0, 0.55);
  }
}

/* One main action on screen: the page's own Marigold button (the album's
   "Add photos") would still show through the backdrop on a wide screen and
   read as a second one next to the sheet's, so while a sheet is open it
   looks like the plain buttons beside it (keeping the dock's shape). It's
   inert behind the sheet anyway; focus comes back to it only once the
   sheet is gone. */
:root:has(.upload-backdrop) .btn-main:not(.upload-sheet .btn-main) {
  background: var(--night-btn);
  color: var(--moon);
  box-shadow: inset 0 0 0 1px var(--night-line);
}

.upload-heading {
  font-size: 26px;
  margin: 0 0 16px;
}

.upload-ask-body {
  margin: -6px 0 22px;
  color: var(--moon-quiet);
  font-size: 16px;
  line-height: 1.45;
}

/* ---------- the bar ---------- */

/* The empty part is about 3:1 against the sheet, so how far along it is
   reads at arm's length (night-btn was 1.3:1). */
.upload-bar {
  height: 12px;
  border-radius: 6px;
  background: #5d5d60;
  overflow: hidden;
}

.upload-bar-fill {
  width: 100%;
  height: 100%;
  border-radius: 6px;
  background: var(--moon);
  transform-origin: left center;
  transform: scaleX(var(--progress, 0));
  transition: transform 0.3s ease-out;
}

/* ---------- what it's waiting for, and the lines under it ---------- */

.upload-wait {
  margin-top: 14px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.upload-wait[hidden] {
  display: none;
}

.upload-wait-lines {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.upload-notes {
  margin-top: 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.upload-notes:empty {
  display: none;
}

.upload-note {
  margin: 0;
  font-size: 16px;
  line-height: 1.4;
  color: var(--moon-quiet);
}

/* ---------- failed items ---------- */

.upload-failed {
  margin-top: 14px;
}

.upload-failed[hidden] {
  display: none;
}

.upload-failed-list {
  margin: 0;
  padding: 0;
  list-style: none;
  border-top: 1px solid var(--night-line);
}

.upload-failed-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--night-line);
}

.upload-failed-text {
  flex: 1 1 auto;
  min-width: 0;
}

.upload-failed-name {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  line-height: 1.3;
  overflow-wrap: anywhere;
}

.upload-failed-why {
  margin: 2px 0 0;
  font-size: 15px;
  line-height: 1.4;
  color: var(--moon-quiet);
}

.upload-sheet .upload-retry,
.upload-sheet .upload-retry-all {
  flex: none;
  width: auto;
  padding: 0 18px;
  white-space: nowrap;
}

.upload-failed-more {
  margin: 10px 0 0;
  font-size: 15px;
  color: var(--moon-quiet);
}

.upload-retry-all {
  margin-top: 12px;
}

/* ---------- buttons ---------- */

.upload-actions {
  display: flex;
  gap: 10px;
  margin-top: 22px;
}

/* The buttons never scroll out of view, however many rows fail (fix round
   1: five storage-full rows put "Done" under the fold on a phone). They
   stick to the bottom of the scrolling sheet on its own ground, with a
   short fade above them, and carry the sheet's bottom padding and the
   safe area, so they sit clear of the home indicator. */
.upload-sheet .upload-actions {
  position: sticky;
  bottom: 0;
  padding-bottom: calc(22px + env(safe-area-inset-bottom, 0px));
  background: var(--night);
}

.upload-sheet .upload-actions::before {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  bottom: 100%;
  height: 16px;
  background: linear-gradient(to bottom, rgba(10, 10, 11, 0), var(--night));
  pointer-events: none;
}

@media (min-width: 600px) {
  .upload-sheet .upload-actions {
    padding-bottom: 28px;
  }
}

/* Paired buttons share one size and label size (app.css's .sheet-actions). */
.upload-actions .btn {
  flex: 1 1 0;
  height: 56px;
  font-size: 17px;
  white-space: nowrap;
}
