/* World Choir — post-event Memory tab
   Same visual DNA as Donate. Theme tokens live in world-choir-theme.css. */

.memory-page {
  position: relative;
  z-index: 1;
  max-width: 100%;
  width: 100%;
  margin: 0 auto;
  /* Match Donate: 14px content gap + safe-area so the World Choir logo sits at the same top offset */
  padding: calc(14px + env(safe-area-inset-top, 0px)) 20px calc(var(--nav-height) + 88px);
  font-family: var(--font-sans);
  color: var(--df-warm);
  overflow-x: clip;
}

.memory-page * {
  box-sizing: border-box;
}

.mem-topbar {
  margin-bottom: 18px;
}

.mem-intro {
  margin: 0 0 22px;
  text-align: left;
}

.mem-intro__title {
  margin: 0 0 10px;
}

.mem-intro__kicker {
  margin: 0;
  font-size: 0.62rem;
  font-weight: 500;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--df-muted);
}

.mem-section {
  margin: 28px 0 0;
}

.mem-section-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.mem-section-row .df-section-label,
.mem-section-row__label {
  margin: 0;
}

.mem-link {
  flex-shrink: 0;
  font-size: 0.62rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  text-decoration: none;
  color: var(--df-accent);
}

.mem-link:hover,
.mem-link:focus-visible {
  text-decoration: underline;
  outline: none;
}

.mem-card {
  display: block;
  background: var(--mem-card-bg);
  border: 1px solid var(--df-line);
  border-radius: 12px;
  text-decoration: none;
  color: inherit;
}

.mem-empty {
  margin: 0;
  padding: 20px 8px;
  text-align: center;
  font-size: 0.88rem;
  line-height: 1.5;
  color: var(--df-muted);
}

.mem-empty--soft {
  padding: 8px 0 28px;
  text-align: left;
}

/* ─── Carousel (Instagram-like horizontal paging) ─── */

.mem-carousel {
  margin: 0 0 8px;
}

.mem-carousel__viewport {
  overflow: hidden;
  outline: none;
  /* Vertical page scroll until the gesture locks to X — then JS preventDefault. */
  touch-action: pan-y;
  padding: 8px 0 4px;
  user-select: none;
  -webkit-user-select: none;
  cursor: grab;
}

.mem-carousel__viewport.is-dragging,
.mem-carousel__viewport.is-snapping {
  cursor: grabbing;
  touch-action: none;
}

/*
 * While dragging / snapping, every photo is already center-sized.
 * That removes the slow “side → center open” after the swipe (IG-style).
 */
.mem-carousel__viewport.is-dragging .mem-carousel__slot:not(.mem-carousel__slot--empty):not(.mem-carousel__slot--waiting):not(.mem-carousel__slot--loading):not(.mem-carousel__slot--empty-state),
.mem-carousel__viewport.is-snapping .mem-carousel__slot:not(.mem-carousel__slot--empty):not(.mem-carousel__slot--waiting):not(.mem-carousel__slot--loading):not(.mem-carousel__slot--empty-state) {
  width: min(58vw, 280px);
  height: 240px;
  opacity: 1;
  transform: none;
  box-shadow: 0 0 0 1px rgba(78, 197, 232, 0.18);
}

.mem-carousel__viewport.is-dragging .mem-carousel__slot--left,
.mem-carousel__viewport.is-dragging .mem-carousel__slot--right,
.mem-carousel__viewport.is-snapping .mem-carousel__slot--left,
.mem-carousel__viewport.is-snapping .mem-carousel__slot--right {
  opacity: 0.5;
  box-shadow: 0 0 0 1px var(--border-subtle);
}

.mem-carousel__viewport:focus-visible {
  box-shadow: 0 0 0 2px rgba(78, 197, 232, 0.35);
  border-radius: 12px;
}

.mem-carousel__stage {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  min-height: 240px;
  width: 100%;
  will-change: transform;
  backface-visibility: hidden;
}

.mem-carousel__slot {
  flex: 0 0 auto;
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 0 0 1px var(--border-subtle);
  background: var(--surface-lift-mid);
  /* Instant geometry — never animate side→center size (that felt like a 2nd move). */
  transition: none !important;
  width: min(32vw, 150px);
  height: 180px;
  opacity: 0.88;
  transform: scale(0.82);
}

.mem-carousel__slot--center,
.mem-carousel__slot.is-active {
  width: min(58vw, 280px);
  height: 240px;
  opacity: 1;
  transform: none;
  box-shadow: 0 0 0 1px rgba(78, 197, 232, 0.22);
}

.mem-carousel__slot--empty {
  visibility: hidden;
  pointer-events: none;
  box-shadow: none;
  background: transparent;
}

.mem-carousel__slot--waiting,
.mem-carousel__slot--loading,
.mem-carousel__slot--empty-state {
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0.95;
  transform: scale(0.9);
}

.mem-carousel__slot--empty-state {
  width: min(72vw, 320px);
  height: 200px;
  opacity: 1;
  transform: none;
}

.mem-carousel__waiting {
  padding: 16px 14px;
  text-align: center;
}

.mem-carousel__waiting-title {
  margin: 0;
  font-size: 0.92rem;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.88);
  line-height: 1.35;
}

.mem-carousel__waiting-sub {
  margin: 8px 0 0;
  font-size: 0.78rem;
  line-height: 1.4;
  color: rgba(255, 255, 255, 0.48);
}

.mem-carousel__img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  pointer-events: none;
  user-select: none;
  transform-origin: center center;
  will-change: opacity, transform;
}

.mem-carousel__meta {
  margin: 12px 20px 0;
  text-align: center;
  min-height: 2.4em;
  transition: opacity 180ms ease;
}

.mem-carousel__meta.is-dimmed {
  opacity: 0.35;
}

.mem-carousel__caption {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.9);
  line-height: 1.35;
}

.mem-carousel__place {
  margin: 4px 0 0;
  font-size: 0.78rem;
  color: rgba(255, 255, 255, 0.5);
  letter-spacing: 0.02em;
}

.mem-carousel__dots {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  margin-top: 14px;
  min-height: 12px;
}

.mem-carousel__dot {
  width: 6px;
  height: 6px;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.28);
  transition: width 320ms cubic-bezier(0.32, 0.72, 0, 1), background 240ms ease;
}

.mem-carousel__dot.is-active {
  width: 18px;
  background: var(--df-accent);
}

.mem-carousel--empty .mem-carousel__dots {
  opacity: 0.7;
}

@media (prefers-reduced-motion: reduce) {
  .mem-carousel__slot,
  .mem-carousel__stage,
  .mem-carousel__meta,
  .mem-carousel__dot {
    transition: none !important;
  }
}

/* ─── Event card ─── */

.mem-event-card {
  padding: 16px;
}

.mem-event-card__top {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  margin-bottom: 18px;
}

.mem-event-card__art {
  width: 84px;
  height: 112px;
  object-fit: cover;
  border-radius: 10px;
  flex-shrink: 0;
  background: var(--bg-secondary);
  border: 1px solid var(--df-line);
}

.mem-event-card__meta {
  min-width: 0;
  padding-top: 2px;
}

.mem-event-card__title {
  margin: 0 0 10px;
  font-size: 1.15rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.25;
  color: var(--df-warm);
}

.mem-event-card__line {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin: 0;
  font-size: 0.78rem;
  color: var(--df-muted);
}

.mem-event-card__chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.mem-event-card__icon {
  display: inline-flex;
  width: 14px;
  height: 14px;
  color: var(--df-muted);
}

.mem-event-card__icon svg {
  width: 14px;
  height: 14px;
}

.mem-event-card__sep {
  opacity: 0.45;
}

.mem-event-card__stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  border-top: 1px solid var(--df-line);
  padding-top: 14px;
}

.mem-stat {
  position: relative;
  text-align: center;
  padding: 0 4px;
  min-width: 0;
}

.mem-stat:not(:last-child)::after {
  content: '';
  position: absolute;
  top: 12%;
  right: -4px;
  width: 1px;
  height: 76%;
  background: var(--df-line);
}

.mem-stat__icon {
  display: inline-flex;
  width: 16px;
  height: 16px;
  color: var(--df-accent);
  margin-bottom: 6px;
}

.mem-stat__icon svg {
  width: 16px;
  height: 16px;
}

.mem-stat__value {
  display: block;
  font-size: clamp(0.72rem, 2.6vw, 0.92rem);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
  color: var(--df-warm);
  line-height: 1.2;
  white-space: nowrap;
}

.mem-stat__label {
  display: block;
  margin-top: 4px;
  font-size: 0.52rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--df-muted);
  line-height: 1.25;
}

.mem-stat__label--stack {
  letter-spacing: 0.06em;
}

@media (max-width: 520px) {
  .mem-event-card__stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    row-gap: 14px;
  }

  .mem-stat:nth-child(2)::after,
  .mem-stat:nth-child(even)::after {
    display: none;
  }
}

/* ─── Passport + stamps ─── */

.mem-stamps-section {
  margin-top: 28px;
}

.mem-stamps-card {
  position: relative;
  overflow: hidden;
  padding: 14px 12px 16px;
  background-color: transparent;
  background-image: url('../images/passport/passport-inside-bg.png?v=20260827c');
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
}

.mem-stamps-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px 6px;
  align-items: center;
  justify-items: center;
  min-height: 52px;
}

.mem-stamp-slot {
  width: 100%;
  max-width: 48px;
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
}

.mem-stamp-slot--empty {
  visibility: hidden;
}

.mem-stamp-slot__img {
  width: 100%;
  height: 100%;
  max-width: 44px;
  max-height: 44px;
  object-fit: contain;
  display: block;
  pointer-events: none;
  user-select: none;
}

/* ─── Pass the World route ─── */

.mem-route-card {
  padding: 18px 8px 14px;
  overflow: hidden;
}

.mem-route {
  display: flex;
  gap: 0;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  padding: 0 8px 4px;
}

.mem-route::-webkit-scrollbar {
  display: none;
}

.mem-route__stop {
  position: relative;
  flex: 0 0 auto;
  width: 104px;
  text-align: center;
  padding-top: 4px;
}

.mem-route__line {
  position: absolute;
  top: 11px;
  right: calc(50% + 8px);
  width: calc(100% - 16px);
  border-top: 1px dashed var(--border-soft);
  pointer-events: none;
}

.mem-route__node {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 1.5px solid rgba(255, 255, 255, 0.35);
  background: transparent;
  margin-bottom: 10px;
  position: relative;
  z-index: 1;
}

.mem-route__stop--completed .mem-route__node,
.mem-route__stop--current .mem-route__node {
  background: var(--df-accent);
  border-color: var(--df-accent);
  box-shadow: 0 0 0 3px rgba(78, 197, 232, 0.16);
}

.mem-route__city {
  margin: 0 0 2px;
  font-size: 0.72rem;
  font-weight: 600;
  color: rgba(242, 239, 232, 0.78);
  line-height: 1.25;
}

.mem-route__country {
  margin: 0 0 6px;
  font-size: 0.58rem;
  color: var(--df-muted);
  line-height: 1.25;
}

.mem-route__date {
  margin: 0;
  font-size: 0.58rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--df-muted);
}

.mem-route__stop--current .mem-route__city,
.mem-route__stop--current .mem-route__date,
.mem-route__stop--completed .mem-route__city {
  color: var(--df-accent);
}

.mem-route__stop--completed .mem-route__line {
  border-top-color: rgba(78, 197, 232, 0.45);
}

/* ─── World Chain – Completed (latest card) ─── */

.mem-world-chain-wrap {
  margin: 0;
}

.mem-world-chain-wrap .wc-chain-card {
  text-align: left;
  margin: 0;
}

.mem-world-chain-wrap .wc-chain-card__cta {
  text-decoration: none;
  -webkit-tap-highlight-color: transparent;
}

.mem-world-chain-wrap .wc-chain-card__cta:hover,
.mem-world-chain-wrap .wc-chain-card__cta:focus-visible {
  text-decoration: none;
}

/* ─── Floating actions ─── */

.mem-fab {
  position: fixed;
  right: max(16px, env(safe-area-inset-right));
  bottom: calc(var(--nav-height) + 12px + env(safe-area-inset-bottom, 0px));
  z-index: 120;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 10px;
}

.mem-fab__toggle,
.mem-fab__action {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  cursor: pointer;
  color: var(--df-accent);
  background: var(--bg-secondary);
  border: 1.5px solid var(--df-accent);
  box-shadow: 0 0 18px rgba(78, 197, 232, 0.18);
  transition: transform 160ms ease, background 160ms ease, opacity 160ms ease;
}

.mem-fab__toggle svg,
.mem-fab__action svg {
  width: 22px;
  height: 22px;
}

.mem-fab__toggle:hover,
.mem-fab__action:hover,
.mem-fab__toggle:focus-visible,
.mem-fab__action:focus-visible {
  background: rgba(78, 197, 232, 0.08);
  outline: none;
}

.mem-fab.is-open .mem-fab__toggle {
  transform: rotate(45deg);
}

.mem-fab__menu {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 10px;
}

.mem-fab__menu[hidden] {
  display: none !important;
}

.mem-fab__row {
  display: flex;
  align-items: center;
  gap: 10px;
  animation: memFabIn 180ms ease both;
}

.mem-fab__row:nth-child(1) { animation-delay: 40ms; }
.mem-fab__row:nth-child(2) { animation-delay: 80ms; }
.mem-fab__row:nth-child(3) { animation-delay: 120ms; }

.mem-fab__label {
  font-size: 0.72rem;
  font-weight: 500;
  color: var(--df-warm-soft);
  background: rgba(5, 5, 5, 0.88);
  border: 1px solid var(--df-line);
  border-radius: 999px;
  padding: 8px 12px;
  white-space: nowrap;
}

.mem-fab__action {
  width: 48px;
  height: 48px;
}

.mem-fab__action.is-disabled,
.mem-fab__action:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

@keyframes memFabIn {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.96);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@media (prefers-reduced-motion: reduce) {
  .mem-fab__row {
    animation: none;
  }

  .mem-fab.is-open .mem-fab__toggle {
    transform: none;
  }
}

/* ─── Composer ─── */

html.mem-composer-open,
html.mem-composer-open body {
  overflow: hidden !important;
  overscroll-behavior: none;
}

.mem-composer {
  position: fixed;
  inset: 0;
  z-index: 140;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: max(16px, env(safe-area-inset-top, 0px)) 16px max(16px, env(safe-area-inset-bottom, 0px));
  box-sizing: border-box;
  overscroll-behavior: none;
  touch-action: none;
}

.mem-composer[hidden] {
  display: none !important;
}

.mem-composer__backdrop {
  position: absolute;
  inset: 0;
  border: 0;
  background: rgba(0, 0, 0, 0.62);
  cursor: pointer;
  touch-action: none;
}

.mem-composer__sheet {
  position: relative;
  z-index: 1;
  width: min(100%, 420px);
  max-height: min(84vh, 640px);
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  touch-action: pan-y;
  background: #080808;
  border: 1px solid var(--df-line);
  border-radius: 18px;
  padding: 20px 18px;
  margin: 0 auto;
}

.mem-composer__title {
  margin: 0 0 14px;
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--df-warm);
}

.mem-composer__preview {
  min-height: 160px;
  border-radius: 12px;
  border: 1px solid var(--df-line);
  overflow: hidden;
  background: var(--bg-secondary);
  margin-bottom: 14px;
  display: grid;
  place-items: center;
}

.mem-composer__preview img {
  display: block;
  width: 100%;
  max-height: 240px;
  object-fit: cover;
}

.mem-composer__field {
  display: block;
  margin-bottom: 16px;
}

.mem-composer__label {
  display: block;
  margin-bottom: 6px;
  font-size: 0.62rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--df-muted);
}

.mem-composer__optional {
  letter-spacing: 0.06em;
  text-transform: none;
  color: rgba(255, 255, 255, 0.38);
}

.mem-composer__place {
  margin: -6px 0 16px;
  font-size: 0.82rem;
  color: rgba(255, 255, 255, 0.52);
}

.mem-composer__field textarea {
  width: 100%;
  resize: vertical;
  min-height: 84px;
  border-radius: 10px;
  border: 1px solid var(--df-line);
  background: var(--bg-secondary);
  color: var(--df-warm);
  font: inherit;
  padding: 12px;
}

.mem-composer__field textarea:focus-visible {
  outline: none;
  border-color: rgba(78, 197, 232, 0.45);
}

.mem-composer__actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

.mem-composer__btn {
  border: 0;
  border-radius: 999px;
  padding: 12px 18px;
  font: inherit;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
}

.mem-composer__btn--ghost {
  background: transparent;
  color: var(--df-muted);
  border: 1px solid var(--df-line);
}

.mem-composer__btn--primary {
  background: var(--df-accent);
  color: #041016;
}

.mem-toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--nav-height) + 84px);
  transform: translateX(-50%) translateY(12px);
  z-index: 160;
  max-width: min(90vw, 360px);
  padding: 10px 14px;
  border-radius: 999px;
  background: rgba(8, 8, 8, 0.94);
  border: 1px solid var(--df-line);
  color: var(--df-warm-soft);
  font-size: 0.78rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms ease, transform 180ms ease;
}

.mem-toast.is-visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
