/* ── Buttons ── */
.btn {
  display: inline-flex;
  flex-direction: row;
  justify-content: center;
  align-items: center;
  box-sizing: border-box;
  border-radius: 8px;
  border: none;
  font-family: inherit;
  font-weight: 700;
  font-size: 16px;
  line-height: 20px;
  text-align: center;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
}

/* Primary */
.primary-m, .primary-l {
  background: var(--color-primary);
  color: var(--color-surface);
}
.primary-m:disabled, .primary-l:disabled {
  background: var(--color-surface-muted);
  color: var(--color-text-muted);
  cursor: not-allowed;
}
.primary-m { padding: 12px 24px; gap: 8px; min-height: 48px; }
.primary-l { padding: 16px 32px; gap: 8px; min-height: 56px; }

/* Secondary */
.secondary-s, .secondary-m {
  background: var(--color-surface);
  border: 4px solid var(--color-primary);
  color: var(--color-text);
}
.secondary-s:active, .secondary-m:active { background: var(--color-surface-pressed); }
.secondary-s { padding: 4px 12px; gap: 4px; min-height: 32px; }
.secondary-m { padding: 12px 24px; gap: 8px; min-height: 48px; }

/* Tertiary */
.tertiary-s, .tertiary-m, .tertiary-l {
  background: var(--color-surface);
  border: 2px solid var(--color-border-soft);
  color: var(--color-text);
}
.tertiary-s:active, .tertiary-m:active, .tertiary-l:active { background: var(--color-surface-pressed); }
.tertiary-s { padding: 4px 8px; gap: 4px; min-height: 32px; }
.tertiary-m { padding: 12px 16px; gap: 8px; min-height: 48px; }
.tertiary-l { padding: 16px 32px; gap: 8px; min-height: 56px; }

/* Navigation */
.navigation-s {
  padding: 12px 8px;
  gap: 4px;
  min-height: 48px;
  border: none;
  background: transparent;
  border-radius: 8px;
  font-weight: 700;
  font-size: 13px;
  line-height: 16px;
  color: var(--color-text);
}
.navigation-s:disabled {
  opacity: 0.4;
  cursor: default;
}

.btn-nav-icon {
  width: 16px;
  height: 16px;
  background-color: var(--color-black);
  mask-size: contain;
  mask-repeat: no-repeat;
  mask-position: center;
}
.btn-nav-icon--left {
  mask-image: url("../icons/CaretUp.b31bd2671f87.svg");
  transform: rotate(-90deg);
}
.btn-nav-icon--right {
  mask-image: url("../icons/CaretUp.b31bd2671f87.svg");
  transform: rotate(90deg);
}

/* ── Icon masks (shared) ── */
/* Single-color icons rendered via CSS mask-image so they can be recolored with background-color. */
.status-tag-icon,
.alert-icon,
.btn-social-icon,
.header-action-icon--mail,
.accordion-icon {
  flex: none;
  display: block;
  mask-size: contain;
  mask-repeat: no-repeat;
  mask-position: center;
}

/* ── Hyperlinks ── */
.hyperlink-s {
  display: inline-flex;
  flex-direction: row;
  align-items: center;
  gap: 4px;
  font-weight: 400;
  font-size: 13px;
  line-height: 16px;
  text-align: center;
  text-decoration-line: underline;
  color: var(--color-text-muted);
}
.hyperlink-s-icon {
  flex: none;
  width: 12px;
  height: 12px;
  display: block;
  object-fit: contain;
}

.hyperlink-m {
  box-sizing: border-box;
  display: inline-flex;
  flex-direction: row;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
  background: var(--color-surface-muted);
  border-radius: 8px;
  font-weight: 400;
  font-size: 16px;
  line-height: 20px;
  text-align: center;
  text-decoration-line: underline;
  color: var(--color-text);
}
.hyperlink-m-icon {
  flex: none;
  width: 20px;
  height: 20px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--color-text);
}
.hyperlink-m-wrap {
  display: flex;
  justify-content: center;
  width: 100%;
}

/* ── Edit data page ── */
.section--edit-data {
  align-items: center;
}

.edit-data-shell {
  width: 100%;
  max-width: 360px;
  display: flex;
  flex-direction: column;
  gap: 24px;
  padding-top: 8px;
}

.edit-data-back {
  align-self: flex-start;
}

.edit-data-divider {
  border-top: 1px solid var(--color-border);
}

@media (min-width: 1024px) {
  .edit-data-shell {
    position: relative;
    max-width: 480px;
  }
  .edit-data-back {
    position: absolute;
    right: 100%;
    top: 4px;
    margin-right: 24px;
    white-space: nowrap;
  }
}

/* ── Status tag ── */
.status-tag {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 4px 8px;
  font-family: inherit;
  font-weight: 400;
  font-size: 13px;
  line-height: 16px;
  text-decoration: none;
  white-space: nowrap;
}
.status-tag-icon {
  width: 16px;
  height: 16px;
  background-color: var(--color-info);
}
.status-tag--danger .status-tag-icon {
  background-color: var(--color-text);
}
.status-tag--warning .status-tag-icon {
  background-color: var(--color-warning);
}
.status-tag-icon--hourglass {
  mask-image: url("../icons/HourglassMedium.902473efec47.svg");
}
.status-tag-icon--check-square-offset {
  mask-image: url("../icons/CheckSquareOffset.31b4dfdcce75.svg");
}
.status-tag-icon--check {
  mask-image: url("../icons/CheckCircle.2388da220d08.svg");
}
.status-tag-icon--note-pencil {
  mask-image: url("../icons/NotePencil.9118596c97b1.svg");
}
.status-tag-icon--truck {
  mask-image: url("../icons/Truck.4834e93e0815.svg");
}
.status-tag--neutral {
  background: var(--color-info-bg-soft);
  border-radius: 16px;
  color: var(--color-info-dark);
}
.status-tag--success {
  background: var(--color-success-bg-soft);
  border-radius: 16px;
  color: var(--color-success-dark);
}
.status-tag--success .status-tag-icon {
  background-color: var(--color-success);
}
.status-tag--warning {
  background: var(--color-warning-bg-soft);
  border-radius: 16px;
  color: var(--color-warning-dark);
}
.status-tag--danger {
  background: var(--color-surface-muted);
  border-radius: 16px;
  color: var(--color-text);
}
.status-tag--ready {
  background: var(--color-primary);
  border-radius: 16px;
  color: var(--color-surface);
}

/* ── Alert ── */
.alert {
  box-sizing: border-box;
  display: flex;
  flex-direction: row;
  align-items: flex-start;
  gap: 4px;
  width: 100%;
  padding: 12px;
  background: var(--color-surface);
  border: 1px solid var(--color-info);
  border-radius: 8px;
}
.alert--success {
  border-color: var(--color-success);
}
.alert--warning {
  border-color: var(--color-warning);
}
.alert-icon {
  width: 20px;
  height: 20px;
  margin: 2px;
  background-color: var(--color-info);
  mask-image: url("../icons/Info.e1d6c836dd45.svg");
}
.alert-icon--success {
  background-color: var(--color-success);
  mask-image: url("../icons/CheckCircle.2388da220d08.svg");
}
.alert-icon--warning {
  background-color: var(--color-warning);
  mask-image: url("../icons/WarningCircle.af27dedf47c7.svg");
}
.alert-text {
  flex: 1;
  min-width: 0;
  font-weight: 400;
  font-size: 16px;
  line-height: 24px;
  color: var(--color-text);
}
/* ── Social buttons ── */
.social-buttons { display: flex; flex-direction: row; align-items: center; gap: 8px; width: 100%; margin-top: 8px}
.btn-social {
  box-sizing: border-box;
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  gap: 4px;
  padding: 16px;
  border-radius: 16px;
  border: none;
  font-weight: 700;
  font-size: 16px;
  line-height: 20px;
  color: var(--color-surface);
  cursor: pointer;
  text-decoration: none;
}
.btn-social-icon {
  width: 20px;
  height: 20px;
  background-color: var(--color-surface);
}
.btn-facebook .btn-social-icon { mask-image: url("../icons/FacebookLogo.ef7fb7ab81f4.svg"); }
.btn-instagram .btn-social-icon { mask-image: url("../icons/InstagramLogo.47117ac73873.svg"); }
.btn-facebook { background: #0064E0; }
.btn-instagram { background: linear-gradient(104.04deg, #F9CE34 0%, #EE2A7B 50%, #6228D7 100%); }

/* ── Input text ── */
.form-field {
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  width: 100%;
}

/* Label row: label text + optional "(optional)" hint */
.form-field-label {
  display: flex;
  align-items: center;
  width: 100%;
}
.form-field-label-text {
  flex: 1;
  font-weight: 700;
  font-size: 16px;
  line-height: 20px;
  color: var(--color-text);
}
.form-field-label-optional {
  flex: none;
  font-style: italic;
  font-weight: 400;
  font-size: 16px;
  line-height: 20px;
  color: var(--color-text-muted);
}

/* Helper description text below the label. Hugs the label row above it
   (no gap) — only cancels the parent .form-field's gap on that one edge,
   the gap before the input below stays untouched. */
.form-field-description {
  width: 100%;
  font-weight: 400;
  font-size: 13px;
  line-height: 16px;
  color: var(--color-text);
}
.form-field-label + .form-field-description {
  margin-top: -8px;
}

/* Input box: State=Default */
.form-field-input {
  box-sizing: border-box;
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 4px;
  width: 100%;
  height: 48px;
  padding: 0 16px;
  background: var(--color-surface);
  border: 1px solid var(--color-border-strong);
  border-radius: 8px;
}
.form-field-input input {
  flex: 1;
  min-width: 0;
  border: none;
  outline: none;
  background: transparent;
  font-family: inherit;
  font-weight: 400;
  font-size: 16px;
  line-height: 20px;
  color: var(--color-text);
  -moz-appearance: textfield;
  appearance: textfield;
}
.form-field-input--readonly {
  background: var(--color-surface-muted);
}
.form-field-input--readonly input {
  color: var(--color-text-muted);
  cursor: not-allowed;
}
.form-field-input input::-webkit-outer-spin-button,
.form-field-input input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
.form-field-input select {
  flex: none;
  min-width: 0;
  border: none;
  outline: none;
  background: transparent;
  font-family: inherit;
  font-weight: 400;
  font-size: 16px;
  line-height: 20px;
  color: var(--color-text);
  cursor: pointer;
}
.form-field-suffix {
  flex: none;
  font-weight: 400;
  font-size: 16px;
  line-height: 20px;
  color: var(--color-text-muted);
}

.form-field-toggle {
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  padding: 0;
  border: none;
  background: none;
  cursor: pointer;
}

.form-field-toggle-icon {
  width: 20px;
  height: 20px;
  background-color: var(--color-text);
  mask-image: url("../icons/Eye.891400bad9cd.svg");
  mask-size: contain;
  mask-repeat: no-repeat;
  mask-position: center;
  -webkit-mask-image: url("../icons/Eye.891400bad9cd.svg");
  -webkit-mask-size: contain;
  -webkit-mask-repeat: no-repeat;
  -webkit-mask-position: center;
}

.form-field-toggle[aria-pressed="true"] .form-field-toggle-icon {
  background-color: var(--color-primary);
}

/* State=Focus */
.form-field-input:focus-within {
  border: 1px solid var(--color-text);
  box-shadow: 0 0 0 1px var(--color-surface), 0 0 0 3px var(--color-text);
}

/* State=Error */
.form-field.is-invalid .form-field-input {
  border: 2px dashed var(--color-warning);
}

/* Error row below a field: warning icon + message (caption/md) */
.form-field-error {
  display: flex;
  flex-direction: row;
  align-items: flex-start;
  gap: 4px;
  width: 100%;
  margin: 0;
  font-weight: 400;
  font-size: 16px;
  line-height: 20px;
  color: var(--color-warning-dark);
}

.form-field-error[hidden] {
  display: none;
}

.form-field-error-icon {
  flex: none;
  width: 20px;
  height: 20px;
  background-color: var(--color-warning);
  mask-image: url("../icons/Warning.2be9b6fb2db6.svg");
  mask-size: contain;
  mask-repeat: no-repeat;
  mask-position: center;
  -webkit-mask-image: url("../icons/Warning.2be9b6fb2db6.svg");
  -webkit-mask-size: contain;
  -webkit-mask-repeat: no-repeat;
  -webkit-mask-position: center;
}

/* Muted helper text below a field/button (caption/sm) */
.form-field-hint {
  font-weight: 400;
  font-size: 13px;
  line-height: 16px;
  color: var(--color-text-muted);
  width: 100%;
}

/* ── Menu button ── */
.menu-btn {
  box-sizing: border-box;
  display: inline-flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 98px;
  height: 48px;
  min-height: 48px;
  padding: 12px 16px;
  background: var(--color-overlay-ghost);
  border: none;
  border-radius: 8px;
  font-family: inherit;
  font-weight: 400;
  font-size: 16px;
  line-height: 20px;
  text-align: center;
  color: var(--color-black);
  cursor: pointer;
}
.menu-btn-label {
  display: inline-block;
}
.menu-btn-icon {
  flex: none;
  flex-basis: 20px;
  width: 20px;
  height: 20px;
  min-width: 20px;
  min-height: 20px;
  display: block;
  object-fit: contain;
}
.menu-btn:not(.menu-btn--close) .menu-btn-icon {
  margin-right: 8px;
}

/* ── Icon button (square, bordered) — shared by menu close + letter close ── */
.icon-btn {
  width: 48px;
  height: 48px;
  min-height: 48px;
  padding: 12px;
  background: var(--color-surface);
  border: 2px solid var(--color-border-soft);
}

/* ── Header action buttons ── */
.header-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  padding: 0 16px;
  border-radius: 8px;
  font-family: inherit;
  font-weight: 400;
  font-size: 16px;
  line-height: 20px;
  text-align: center;
  text-decoration: none;
}
.header-action--light {
  background: var(--color-surface);
  color: var(--color-text);
}
.header-action--ghost {
  background: var(--color-overlay-ghost);
  color: var(--color-black);
}
.header-action-icon {
  flex: none;
  width: 20px;
  height: 20px;
  display: block;
}
.header-action-icon--mail,
.header-action-icon--edit,
.header-action-icon--logout {
  background-color: var(--color-primary);
  mask-size: contain;
  mask-repeat: no-repeat;
  mask-position: center;
}
.header-action-icon--mail {
  mask-image: url("../icons/Mail.1fb58f5c40dc.svg");
}
.header-action-icon--edit {
  mask-image: url("../icons/NotePencil.9118596c97b1.svg");
}
.header-action-icon--logout {
  mask-image: url("../icons/SignOut.d791b16c2145.svg");
}
.header-action-label {
  display: inline-block;
}

@media (min-width: 1024px) {
  .header-action-icon--edit,
  .header-action-icon--logout {
    background-color: var(--color-text);
  }
}

/* ── Highlight card ── */
.highlight-card {
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  padding: 24px;
  gap: 8px;
  width: 100%;
  background: linear-gradient(180deg, var(--color-highlight-gradient-start) 0%, var(--color-highlight-gradient-end) 100%);
  border: 1px solid var(--color-border-soft);
  box-shadow: var(--shadow-default);
  border-radius: 24px;
}

.highlight-deadline {
  display: flex;
  align-items: flex-start;
  gap: 4px;
  width: 100%;
}

.highlight-deadline-icon {
  flex: none;
  width: 20px;
  height: 20px;
  background-color: var(--color-warning);
  mask-image: url("../icons/CalendarDots.7cbaef5d6644.svg");
  mask-repeat: no-repeat;
  mask-size: contain;
  mask-position: center;
}

.highlight-deadline-text {
  flex: 1;
  font-weight: 700;
  line-height: 20px;
}

.highlight-deadline-text--regular {
  font-weight: 400;
}

.highlight-points-list {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  width: 100%;
  list-style: none;
}

.highlight-point {
  display: flex;
  flex-direction: row;
  align-items: flex-start;
  width: 100%;
}

.highlight-point-bullet {
  flex: none;
  width: 12px;
  font-size: 16px;
  line-height: 24px;
  color: var(--color-primary-dark);
}

.highlight-point-text {
  flex: 1;
  font-size: 16px;
  line-height: 24px;
  color: var(--color-text);
}

/* ── Quantity field ── */
.qty-row {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 8px;
  width: 100%;
}
.qty-input { width: 64px; flex: none; }
/* State=Error. Same dashed warning border as .form-field.is-invalid, spelled
   out here because the input sits directly in the .qty-row flex row, with no
   .form-field wrapper to hang that rule off. */
.qty-input.is-invalid {
  border: 2px dashed var(--color-warning);
}

/* ── E-mail list ── */
.email-list {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  padding: 12px 0 24px;
  width: 100%;
}
.email-row {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 8px 0;
}
.email-row:not(:first-child) {
  border-top: 1px solid var(--color-border);
}
.email-row-address {
  flex: 1;
  min-width: 0;
  overflow-wrap: break-word;
  word-break: break-word;
  font-weight: 400;
  font-size: 16px;
  line-height: 20px;
  color: var(--color-text);
}

/* ── FAQ accordion ── */
.faq-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  margin-bottom: 8px;
}
.accordion {
  width: 100%;
  border-bottom: 1px solid var(--color-border);
}
.accordion-title {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 12px 0;
  min-height: 48px;
  cursor: pointer;
  list-style: none;
}
.accordion-title::-webkit-details-marker { display: none; }
.accordion-icon {
  width: 24px;
  height: 24px;
  background-color: var(--color-text);
  mask-image: url("../icons/CaretUp.b31bd2671f87.svg");
  transform: rotate(180deg);
  transition: transform 180ms ease, background-color 180ms ease;
}
.accordion[open] .accordion-icon {
  transform: rotate(0deg);
  background-color: var(--color-primary);
}

/* ── Confirmation modal (shared by the letter detail view and the lists overview) ── */
.modal-is-open,
html.modal-is-open,
body.modal-is-open {
  overflow: hidden;
}

.letter-modal[hidden] {
  display: none !important;
}

.letter-modal {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: 16px;
}

.letter-modal-backdrop {
  position: absolute;
  inset: 0;
  border: none;
  background: var(--color-overlay-dark);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  cursor: pointer;
}

.letter-modal-panel {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  width: 328px;
  max-width: calc(100vw - 32px);
  background: var(--color-surface);
  box-shadow: var(--shadow-default);
  border-radius: 16px;
}

.letter-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 16px;
}

.letter-modal-header h3 {
  min-width: 0;
}

.letter-modal-close {
  flex: none;
}

.letter-modal-body {
  padding: 0 16px;
}

.letter-modal-body p + p {
  margin-top: 8px;
}

.letter-modal-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 16px;
}

.letter-modal-actions .btn {
  width: 100%;
}
.accordion-title-text {
  flex: 1;
  font-weight: 700;
  font-size: 16px;
  line-height: 20px;
  color: var(--color-text);
}
.accordion-content {
  padding: 0 0 16px 28px;
  font-weight: 400;
  font-size: 16px;
  line-height: 24px;
  color: var(--color-text);
}

/* ── Contact card ── */
.highlight-card--plain {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
}
.contact-card-content {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
  width: 100%;
}
.contact-card-email {
  font-weight: 400;
  font-size: 16px;
  line-height: 20px;
  text-decoration-line: underline;
  color: var(--color-text-muted);
  overflow-wrap: break-word;
  word-break: break-word;
}


/* ── Photo tiles ────────────────────────────────────────────────────────────
   The grid of photos on the two forms that upload them: the pages of a
   letter on the institution page, and the photos of one gift proposal on the
   santa's letter page. Both are driven by static/js/photo-tiles.js, which is
   why the classes are shared and only the layout of the grid differs.

   Nothing here ever shows a file name. What is stored is named at random
   (apps/santa/images._new_name), so the name says nothing about the photo once
   it is saved. */
.photo-tiles {
  display: flex;
  gap: 8px;
}

.photo-tiles:empty {
  display: none;
}

/* The pages of a letter, stacked one under another at their own aspect ratios
   - no cropping and no separate small copy. Reading them is the whole point of
   the card, so they get its full width; a letter that runs to four pages is a
   long card, which is the right trade. */
.photo-tiles--pages {
  flex-direction: column;
}

/* A gift, on the other hand, is looked at rather than read: the tiles are
   square and sit in a row that wraps, so five of them are five glances and not
   five screens of scrolling. */
.photo-tiles--grid {
  flex-wrap: wrap;
}

.photo-tile {
  position: relative;
  border-radius: 8px;
  overflow: hidden;
  background: var(--color-surface-muted);
  border: 1px solid var(--color-border);
}

.photo-tiles--pages .photo-tile {
  width: 100%;
}

.photo-tiles--grid .photo-tile {
  width: 96px;
  height: 96px;
  flex: 0 0 auto;
}

.photo-tile-image {
  display: block;
  width: 100%;
  height: auto;
}

/* Cropped to the square rather than letterboxed inside it: a gift photographed
   in portrait would otherwise be a thin strip between two grey bars. The full
   photo is one tap away in the gallery. */
.photo-tiles--grid .photo-tile-image {
  height: 100%;
  object-fit: cover;
}

/* Ticked for deletion: faded, not gone. Nothing is actually removed until the
   form is saved, and the photo has to stay visible enough to un-tick. */
.photo-tile.is-removed .photo-tile-image {
  opacity: 0.35;
}

/* The tick sits on the photo rather than under it: with the scan taking the
   whole card width there is no room for a button row beside it. */
.photo-tile-remove {
  position: absolute;
  top: 8px;
  right: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 8px;
  background: var(--color-surface);
  box-shadow: var(--shadow-default);
  cursor: pointer;
}

/* A 40px control on a 96px tile would cover most of the gift, so on the grid
   it shrinks and tucks into the corner. */
.photo-tiles--grid .photo-tile-remove {
  top: 4px;
  right: 4px;
  width: 28px;
  height: 28px;
  border-radius: 6px;
}

.photo-tile-remove:active {
  background: var(--color-surface-pressed);
}

/* Clipped, not display:none - the checkbox is the control, and it has to stay
   reachable by keyboard. Same trick as the file input below. */
.photo-tile-remove input[type="checkbox"] {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.photo-tile-remove-icon {
  width: 20px;
  height: 20px;
  background-color: var(--color-text);
  mask-image: url("../icons/Trash.dcb88ebce8bf.svg");
  mask-size: contain;
  mask-repeat: no-repeat;
  mask-position: center;
  -webkit-mask-image: url("../icons/Trash.dcb88ebce8bf.svg");
  -webkit-mask-size: contain;
  -webkit-mask-repeat: no-repeat;
  -webkit-mask-position: center;
}

.photo-tiles--grid .photo-tile-remove-icon {
  width: 14px;
  height: 14px;
}

.photo-tile-remove:has(input:checked) {
  background: var(--color-text);
}

.photo-tile-remove:has(input:checked) .photo-tile-remove-icon {
  background-color: var(--color-surface);
}

.photo-tile-remove:has(input:focus-visible) {
  box-shadow: 0 0 0 1px var(--color-surface), 0 0 0 3px var(--color-text);
}

/* Stands in for a picture there is none of yet: a PDF picked but not uploaded
   (its pages only exist once the server has rendered them), or a HEIC this
   browser cannot decode. A mark rather than the file name - see the note at
   the top of this section.

   The pages stack shrink-wraps its contents (the field is a column with
   align-items: flex-start), which for a photo means the width of the photo but
   for a placeholder would mean the width of the mark. Stretched only while
   such a tile is there, so nothing about the photo case changes. */
.photo-tiles--pages:has(.photo-tile-placeholder) {
  align-self: stretch;
}

.photo-tile-placeholder {
  display: block;
  width: 100%;
  min-height: 72px;
  height: 100%;
  background-color: var(--color-text-muted);
  mask-image: url("../icons/Image.7ea4adbf7a12.svg");
  mask-size: 32px;
  mask-repeat: no-repeat;
  mask-position: center;
  -webkit-mask-image: url("../icons/Image.7ea4adbf7a12.svg");
  -webkit-mask-size: 32px;
  -webkit-mask-repeat: no-repeat;
  -webkit-mask-position: center;
}

/* Stands where the photo would be, so a card with nothing on it yet has one
   obvious next step instead of an empty frame plus a control below it. */
.photo-tile-add {
  width: 100%;
}

/* Once there is a photo the full-width button would be the loudest thing on
   the card, so adding the next one gets a quiet row under the grid instead. */
.photo-tile-more {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 8px;
  padding: 10px;
  border: 1px dashed var(--color-border);
  border-radius: 8px;
  font-size: 14px;
  line-height: 20px;
  color: var(--color-text-muted);
  cursor: pointer;
}

.photo-tile-more:active {
  background: var(--color-surface-pressed);
}

.photo-tile-more-icon {
  width: 16px;
  height: 16px;
  background-color: var(--color-text-muted);
  mask-image: url("../icons/Add.b5658c8a4fdb.svg");
  mask-size: contain;
  mask-repeat: no-repeat;
  mask-position: center;
  -webkit-mask-image: url("../icons/Add.b5658c8a4fdb.svg");
  -webkit-mask-size: contain;
  -webkit-mask-repeat: no-repeat;
  -webkit-mask-position: center;
}

/* The rules above set `display` from an author stylesheet, which beats the
   `display: none` the browser gives [hidden] - without this the empty-state
   button would stay on screen under a photo that has just been added. Same
   pattern as .form-field-error[hidden] above. */
.photo-tile[hidden],
.photo-tile-add[hidden],
.photo-tile-more[hidden] {
  display: none;
}

/* The input is reachable by keyboard (it is only clipped, not display:none -
   see the file-input rule below), so the labels it drives have to show that
   focus themselves. */
.photo-tile-field:focus-within .photo-tile-add,
.photo-tile-field:focus-within .photo-tile-more {
  box-shadow: 0 0 0 1px var(--color-surface), 0 0 0 3px var(--color-text);
}

/* Clipped rather than hidden, so it keeps its place in the tab order - the
   same trick .letter-upload-field plays in letter.css. */
.photo-tile-field input[type="file"] {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ── Photo lightbox ─────────────────────────────────────────────────────────
   Full-size photos over a dimmed page, with arrows and a counter when there is
   more than one. Two things use it: the pages of a letter, laid out by the
   server in partials/list/image.html, and the photos of one gift proposal,
   whose slides are built on open from what the card carries
   (partials/list/present_gallery.html).

   Shared classes rather than two copies because the second one arrived wanting
   exactly the first one's appearance - and because a gift gallery and a letter
   gallery sit on the same page from WAIT_FOR_PRESENTS_SEND on, where looking
   different would read as meaning something. */
.photo-lightbox[hidden] {
  display: none !important;
}

.photo-lightbox {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: 16px;
}

.photo-lightbox-backdrop {
  position: absolute;
  inset: 0;
  border: none;
  background: var(--color-overlay-dark);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  cursor: pointer;
}

.photo-lightbox-image[hidden] {
  display: none !important;
}

.photo-lightbox-image {
  position: relative;
  z-index: 1;
  width: auto;
  max-width: min(1200px, calc(100vw - 32px));
  max-height: calc(100vh - 96px);
  border-radius: 16px;
  border: 1px solid var(--color-border-soft);
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.25);
  object-fit: contain;
  background: var(--color-surface);
}

/* Only rendered when there is more than one photo - a single-photo letter,
   or a gift proposal with one shot of it, keeps a lightbox with no controls
   but the close button. */
.photo-lightbox-prev,
.photo-lightbox-next {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 2;
}

.photo-lightbox-prev {
  left: 20px;
}

.photo-lightbox-next {
  right: 20px;
}

/* One icon, rotated - the caret is the only arrow in static/icons. */
.photo-lightbox-arrow {
  width: 18px;
  height: 18px;
  background-color: var(--color-text);
  mask-image: url("../icons/CaretUp.b31bd2671f87.svg");
  mask-repeat: no-repeat;
  mask-size: contain;
  mask-position: center;
  -webkit-mask-image: url("../icons/CaretUp.b31bd2671f87.svg");
  -webkit-mask-repeat: no-repeat;
  -webkit-mask-size: contain;
  -webkit-mask-position: center;
}

.photo-lightbox-arrow--prev {
  transform: rotate(-90deg);
}

.photo-lightbox-arrow--next {
  transform: rotate(90deg);
}

.photo-lightbox-counter {
  position: absolute;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 2;
  margin: 0;
  padding: 4px 12px;
  border-radius: 999px;
  background: var(--color-surface);
  font-size: 12px;
  line-height: 16px;
  font-weight: 600;
  color: var(--color-text);
}

/* The arrows sit on top of the scan on a phone, where there is no room beside
   it - so they move to the bottom, either side of the counter. */
@media (max-width: 600px) {
  .photo-lightbox-prev,
  .photo-lightbox-next {
    top: auto;
    bottom: 16px;
    transform: none;
  }

  .photo-lightbox-prev {
    left: 16px;
  }

  .photo-lightbox-next {
    right: 16px;
  }

  .photo-lightbox-counter {
    bottom: 26px;
  }
}

.photo-lightbox-close {
  position: absolute;
  top: 20px;
  right: 20px;
  z-index: 2;
}

/* The gift gallery builds its slides into a wrapper (it creates them on open,
   see partials/list/present_gallery.html) while the letter's are direct
   children. `display: contents` makes that difference disappear: the images
   are grid items of the lightbox either way, so every rule above applies to
   both without knowing which it is looking at. */
.photo-lightbox-slides {
  display: contents;
}

/* Same reason .photo-tile[hidden] needs saying out loud: the rules above give
   these `position: absolute` from an author stylesheet, which beats the
   `display: none` the browser gives [hidden]. The letter's gallery renders
   them conditionally and never hits this; the gift one toggles them, because
   one lightbox serves proposals with one photo and with five. */
.photo-lightbox-prev[hidden],
.photo-lightbox-next[hidden],
.photo-lightbox-counter[hidden] {
  display: none !important;
}
