/* Achievements overlay (js/modules/achievements.js): the header's Achievements button grows into this black page.
   .is-ready -> header, intro line and cards rise in */
.ach-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  color: var(--color-wordmark);
}

/* The growing button: starts as the pill (its fill colour), ends as the black page */
.ach-sheet {
  position: fixed;
  left: 0;
  top: 0;
  width: 0;
  height: 0;
  background: #000;
  will-change: left, top, width, height;
}
.ach-sheet.is-full {
  inset: 0;
  width: auto;
  height: auto;
  border-radius: 0;
}

.ach-content {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overscroll-behavior: contain;
  pointer-events: none;
}
.ach-overlay.is-ready .ach-content { pointer-events: auto; }

/* Header, intro and cards fade and rise in, one after the other */
.ach-header > *,
.ach-intro,
.ach-item {
  opacity: 0;
  transform: translateY(16px);
  transition: opacity 0.3s ease, transform 0.3s ease;
}
.ach-overlay.is-ready .ach-header > *,
.ach-overlay.is-ready .ach-intro,
.ach-overlay.is-ready .ach-item {
  opacity: 1;
  transform: none;
  transition: opacity 0.5s ease, transform 0.7s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.ach-overlay.is-ready .ach-intro { transition-delay: 0.08s; }
.ach-overlay.is-ready .ach-item { transition-delay: calc(0.18s + var(--i) * 0.07s); }

.ach-close {
  border: 0;
  background: none;
  cursor: pointer;
}

/* The one-liner above the cards */
.ach-intro {
  margin: 0 var(--gutter);
  max-width: 40ch;
  font-family: var(--font-display);
  font-weight: 300;
  font-size: clamp(1.5rem, 2.8vw, 2.4rem);
  line-height: 1.15;
  letter-spacing: -0.01em;
}
.ach-intro:empty { display: none; }

/* One row of cards, scrolled sideways (mouse wheel too, js/modules/wheel-scroll.js) */
.ach-row {
  display: flex;
  gap: var(--card-gap);
  margin: auto 0;
  padding: 2.5rem var(--gutter) var(--gutter);
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  scroll-padding-inline: var(--gutter);
  scrollbar-width: none;
}
.ach-row::-webkit-scrollbar { display: none; }

.ach-item {
  flex: 0 0 clamp(240px, 23vw, 340px);
  scroll-snap-align: start;
}

.ach-card {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
  padding: 0.6rem 0.6rem 1.1rem;
  border: 0;
  border-radius: var(--radius);
  background: #151413;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1), background-color 0.2s ease;
}
.ach-card:hover { transform: translateY(-4px); background: #1e1d1b; }
.ach-card:focus-visible { outline: 2px solid var(--color-wordmark); outline-offset: 3px; }

.ach-thumb {
  position: relative;
  aspect-ratio: 4 / 3;
  border-radius: calc(var(--radius) - 0.6rem);
  overflow: hidden;
  background: #2a2826;
}
.ach-thumb img,
.ach-thumb video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.5s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.ach-card:hover .ach-thumb img,
.ach-card:hover .ach-thumb video { transform: scale(1.05); }

/* "1/3" chip, and a play mark when the thumbnail is a video */
.ach-count {
  position: absolute;
  right: 0.6rem;
  bottom: 0.6rem;
  padding: 0.25rem 0.6rem;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.6);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  font-size: 0.75rem;
  font-weight: 600;
}
.ach-thumb.is-video::after,
.ach-strip-thumb.is-video::after {
  content: "";
  position: absolute;
  inset: 0;
  margin: auto;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.55) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M9 6.5v11l9-5.5z' fill='%23f3ece4'/%3E%3C/svg%3E") center / 22px no-repeat;
}
.ach-strip-thumb.is-video::after { width: 24px; height: 24px; background-size: 13px; }

.ach-title {
  margin: 0.9rem 0.4rem 0;
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.3;
}
.ach-text {
  margin: 0.3rem 0.4rem 0;
  color: rgba(243, 236, 228, 0.6);
  font-size: 0.875rem;
  font-weight: 500;
  line-height: 1.45;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Popup: one achievement's photos and videos, big, with a slider and thumbnails */
.ach-viewer {
  width: 100%;
  height: 100%;
  max-width: none;
  max-height: none;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--color-wordmark);
  flex-direction: column;
}
.ach-viewer[open] { display: flex; animation: ach-pop 0.3s ease; }
.ach-viewer::backdrop {
  background: rgba(0, 0, 0, 0.88);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
}
@keyframes ach-pop {
  from { opacity: 0; transform: scale(0.97); }
}

.ach-viewer-bar {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem var(--gutter);
}
.ach-viewer-title {
  flex: 1;
  min-width: 0;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ach-viewer-count {
  font-size: 0.9rem;
  font-variant-numeric: tabular-nums;
  opacity: 0.6;
}
.ach-viewer-close,
.ach-arrow {
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
  color: inherit;
  cursor: pointer;
  transition: background-color 0.15s, opacity 0.15s, transform 0.15s;
}
.ach-viewer-close:hover,
.ach-arrow:hover { background: rgba(255, 255, 255, 0.2); }
.ach-viewer-close:focus-visible,
.ach-arrow:focus-visible,
.ach-strip-thumb:focus-visible { outline: 2px solid var(--color-wordmark); outline-offset: 2px; }
.ach-viewer-close svg,
.ach-arrow svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* The slides sit side by side and snap one at a time (swipe on touch screens) */
.ach-stage {
  position: relative;
  flex: 1;
  min-height: 0;
}
.ach-track {
  height: 100%;
  display: flex;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  overscroll-behavior-x: contain;
  scrollbar-width: none;
}
.ach-track::-webkit-scrollbar { display: none; }
.ach-slide {
  flex: 0 0 100%;
  height: 100%;
  display: grid;
  grid-template: minmax(0, 1fr) / minmax(0, 1fr); /* the cell is exactly the slide, so the photo shrinks to fit it whole */
  place-items: center;
  padding: 0 calc(var(--gutter) + 56px);
  scroll-snap-align: center;
  scroll-snap-stop: always;
}
.ach-slide img,
.ach-slide video {
  max-width: 100%;
  max-height: 100%;
  border-radius: 12px;
  object-fit: contain;
}

.ach-arrow {
  position: absolute;
  top: 50%;
  margin-top: -22px;
}
.ach-prev { left: var(--gutter); }
.ach-next { right: var(--gutter); }
.ach-arrow:disabled { opacity: 0.25; cursor: default; }
.ach-viewer.is-single .ach-arrow { display: none; }

.ach-strip {
  display: flex;
  justify-content: safe center;
  gap: 0.5rem;
  padding: 1rem var(--gutter) 1.25rem;
  overflow-x: auto;
  scrollbar-width: none;
}
.ach-strip::-webkit-scrollbar { display: none; }
.ach-strip[hidden] { display: none; }
.ach-viewer.is-single .ach-stage { margin-bottom: var(--gutter); }
.ach-strip-thumb {
  position: relative;
  flex-shrink: 0;
  width: 72px;
  height: 54px;
  padding: 0;
  border: 2px solid transparent;
  border-radius: 10px;
  overflow: hidden;
  background: #2a2826;
  opacity: 0.5;
  cursor: pointer;
  transition: opacity 0.15s, border-color 0.15s;
}
.ach-strip-thumb:hover { opacity: 0.85; }
.ach-strip-thumb.is-active { opacity: 1; border-color: var(--color-wordmark); }
.ach-strip-thumb img,
.ach-strip-thumb video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Phones: smaller cards, arrows over the photo, no side padding around it */
@media (max-width: 640px) {
  .ach-item { flex-basis: min(75vw, 280px); }
  .ach-slide { padding: 0 0.75rem; }
  .ach-arrow { width: 38px; height: 38px; margin-top: -19px; background: rgba(0, 0, 0, 0.45); }
  .ach-prev { left: 1rem; }
  .ach-next { right: 1rem; }
}

@media (prefers-reduced-motion: reduce) {
  .ach-header > *,
  .ach-intro,
  .ach-item,
  .ach-overlay.is-ready .ach-header > *,
  .ach-overlay.is-ready .ach-intro,
  .ach-overlay.is-ready .ach-item { transition: none; }
  .ach-viewer[open] { animation: none; }
}
