/* The pop-up for a pack or a bundle (js/features/pack-modal.js). On a computer: the viewers
   left (a bundle's packs under each other, scrolling on their own with a visible scroll bar),
   a short, quiet info column right. On a phone it fills the screen from the bottom, info first. */

.pack-modal {
  width: min(920px, calc(100% - 2 * var(--gutter)));
  max-height: calc(100dvh - 48px);
  margin: auto;
  padding: 0;
  border: 1px solid var(--color-line);
  border-radius: 24px;
  background: var(--color-background);
  color: var(--color-text);
  box-shadow: var(--shadow-frame);
  overflow: hidden;
}

.pack-modal::backdrop {
  background: rgb(0 0 0 / 0.45);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

:root[data-theme="light"] .pack-modal::backdrop {
  background: rgb(255 255 255 / 0.3);
}

/* No scrolling behind the open pop-up. */
:root:has(.pack-modal[open]) {
  overflow: hidden;
}

.pack-modal[open] {
  animation: pack-modal-in 400ms var(--ease-out);
}

.pack-modal[open]::backdrop {
  animation: pack-modal-backdrop-in 400ms var(--ease-in-out);
}

@keyframes pack-modal-in {
  from {
    opacity: 0;
    transform: translateY(16px) scale(0.98);
  }
}

@keyframes pack-modal-backdrop-in {
  from {
    opacity: 0;
  }
}

/* A column: the top bar, then the body filling the rest of the height. */
.pack-modal-panel {
  display: flex;
  flex-direction: column;
  max-height: calc(100dvh - 48px);
}

.pack-modal-top {
  flex: none;
  padding: 14px 20px;
  border-bottom: 1px solid var(--color-line);
  background: var(--color-background);
}

.pack-modal-back {
  display: inline-flex;
  gap: 8px;
  padding: 6px 8px;
  border: 0;
  background: none;
  color: var(--color-text-muted);
  font: inherit;
  font-size: 15px;
  cursor: pointer;
}

.pack-modal-back:hover {
  color: var(--color-text);
}

/* ---------- Layout: viewers left, info right, each scrolling on its own ---------- */

.pack-modal-body {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(280px, 1fr);
}

.pack-modal-viewers,
.pack-modal-info {
  min-width: 0; /* lets a column shrink below its content (the row of pictures scrolls instead) */
  min-height: 0;
  overflow-y: auto;
}

.pack-modal-viewers {
  padding: 28px 28px 32px;
  border-right: 1px solid var(--color-line);
  background: var(--color-frame);
  scrollbar-width: thin;
  scrollbar-color: var(--color-text-muted) transparent;
}

/* A bundle: the packs under each other, with the scroll bar always showing that there is more. */
.pack-modal-viewers.has-several {
  overflow-y: scroll;
}

.pack-modal-info {
  padding: 34px 30px;
}

/* ---------- One viewer ---------- */

.pack-viewer + .pack-viewer {
  margin-top: 44px;
}

.pack-viewer-stage {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px;
}

/* The MacBook stays a bit smaller than the column; the badge sits above its left corner. */
.pack-viewer-screen {
  justify-self: center;
  width: min(100%, 380px);
}

/* Small, above the screen's top left corner: the arrow points down at the © watermark there. */
.pack-viewer-badge {
  display: flex;
  align-items: flex-end;
  gap: 4px;
  margin: 0 0 4px 14px; /* puts the arrow's point right above the watermark */
  color: var(--color-text-muted);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.pack-viewer-badge[hidden] {
  display: none;
}

.pack-viewer-badge svg {
  flex: none;
  width: 22px;
  height: 22px;
  margin-bottom: -8px; /* the arrow's point reaches down to the watermark */
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* In the pop-up the © watermark sits top left, just under the menu bar (css/devices.css). */
.pack-viewer .device-watermark {
  top: 3.6cqw;
  right: auto;
  bottom: auto;
  left: 2.5%;
}

.pack-viewer-arrow,
.pack-viewer-more {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 1px solid var(--color-line);
  border-radius: 50%;
  background: var(--color-background);
  color: var(--color-text);
  cursor: pointer;
}

.pack-viewer-arrow:hover,
.pack-viewer-more:hover {
  background: var(--color-hover);
}

.pack-viewer-arrow svg,
.pack-viewer-more svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.pack-viewer-caption {
  display: flex;
  justify-content: space-between;
  margin: 16px 50px 0;
  color: var(--color-text-soft);
  font-size: 13px;
}

.pack-viewer-counter {
  color: var(--color-text-muted);
  font-variant-numeric: tabular-nums;
}

/* "The collection" (or the pack's name in a bundle) with a long line under it. */
.pack-viewer-heading {
  margin-top: 24px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--color-text-soft);
  font-size: 14px;
  font-weight: 600;
}

/* The row of small pictures (64 px wide, so the MacBook stays the main thing), with a grey line
   under it. The last one in view peeks in under a fade with an arrow that scrolls on. At the
   end of the row both go away. */
.pack-viewer-row {
  position: relative;
  border-bottom: 1px solid var(--color-line);
}

.pack-viewer-thumbs {
  --gap: 8px;
  display: flex;
  gap: var(--gap);
  padding: 14px 2px;
  overflow-x: auto;
  list-style: none;
  scrollbar-width: none;
}

.pack-viewer-thumbs::-webkit-scrollbar {
  display: none;
}

.pack-viewer-thumbs li {
  flex: none;
  width: 64px;
}

.pack-viewer-row::after {
  content: "";
  position: absolute;
  inset: 0 0 0 auto;
  width: 80px;
  pointer-events: none;
  background: linear-gradient(to right, transparent, var(--color-frame) 75%);
  transition: opacity 200ms var(--ease-in-out);
}

.pack-viewer-more {
  position: absolute;
  top: 50%;
  right: 2px;
  z-index: 1;
  width: 30px;
  height: 30px;
  transform: translateY(-50%);
  transition: opacity 200ms var(--ease-in-out);
}

.pack-viewer-row.is-at-end::after,
.pack-viewer-row.is-at-end .pack-viewer-more {
  opacity: 0;
  pointer-events: none;
}

.pack-viewer-thumb {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 10;
  padding: 0;
  border: 0;
  border-radius: 8px;
  outline: 2px solid transparent;
  outline-offset: 2px;
  cursor: pointer;
  transition: opacity 200ms var(--ease-in-out);
}

.pack-viewer-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  pointer-events: none;
}

.pack-viewer-thumb[aria-current="false"] {
  opacity: 0.6;
}

.pack-viewer-thumb:hover,
.pack-viewer-thumb[aria-current="true"] {
  opacity: 1;
}

.pack-viewer-thumb[aria-current="true"] {
  outline-color: var(--color-text);
}

/* ---------- Info: name, price, one line, what you get, buy ---------- */

/* The name in spaced capitals (.spaced-title in css/base.css), a little smaller here. */
.pack-modal-title {
  font-size: 20px;
}

.pack-modal-price {
  margin-top: 10px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--color-line);
  font-size: 20px;
  font-weight: 500;
}

.pack-modal-saving {
  margin-left: 6px;
  color: var(--color-text-muted);
  font-size: 13px;
  font-weight: 400;
}

.pack-modal-text {
  margin-top: 20px;
  color: var(--color-text-soft);
  font-size: 14px;
  line-height: 1.6;
}

.pack-modal-subtitle {
  margin-top: 24px;
  font-size: 14px;
  font-weight: 600;
}

.pack-modal-includes {
  display: grid;
  gap: 8px;
  margin-top: 12px;
  color: var(--color-text-soft);
  font-size: 14px;
  list-style: none;
}

/* A small dot in the headline colours before every line. */
.pack-modal-includes li {
  display: flex;
  align-items: center;
  gap: 10px;
}

.pack-modal-includes li::before {
  content: "";
  flex: none;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--gradient-headline);
}

.pack-modal-buy {
  width: 100%;
  margin-top: 28px;
  padding: 14px 20px;
  border: 0;
  border-radius: var(--radius-pill);
  background: var(--color-button);
  color: var(--color-button-text);
  font: inherit;
  cursor: pointer;
  /* premium look: small spaced capitals */
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

/* The pack's bundle, under the buy button: outlined, quieter than "buy". */
.pack-modal-bundle {
  width: 100%;
  margin-top: 10px;
  padding: 13px 20px;
  border: 1px solid var(--color-line);
  border-radius: var(--radius-pill);
  background: transparent;
  color: var(--color-text);
  font: inherit;
  cursor: pointer;
  /* premium look: small spaced capitals */
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.pack-modal-bundle:hover {
  background: var(--color-hover);
}

.pack-modal-bundle[hidden] {
  display: none;
}

.pack-modal-buy-status {
  min-height: 20px;
  margin-top: 10px;
  color: var(--color-text-muted);
  font-size: 14px;
  text-align: center;
}

.pack-modal-buy-status:empty {
  display: none;
}

/* ---------- Phone: a sheet from the bottom, info first, one scroll ---------- */

@media (max-width: 760px) {
  .pack-modal {
    width: 100%;
    max-width: none;
    max-height: calc(100dvh - 24px);
    margin: auto 0 0;
    border-radius: 22px 22px 0 0;
  }

  .pack-modal[open] {
    animation-name: pack-modal-up;
  }

  @keyframes pack-modal-up {
    from {
      transform: translateY(40px);
      opacity: 0;
    }
  }

  .pack-modal-panel {
    max-height: calc(100dvh - 24px);
    overflow-y: auto;
  }

  .pack-modal-body {
    flex: none; /* as tall as its content, so the sheet scrolls instead of cutting it off */
    display: flex;
    flex-direction: column-reverse; /* info above the viewers */
  }

  .pack-modal-viewers,
  .pack-modal-viewers.has-several,
  .pack-modal-info {
    flex: none; /* full height each: the sheet itself scrolls */
    overflow: visible;
  }

  .pack-modal-info {
    padding: 22px 20px 24px;
  }

  .pack-modal-title {
    font-size: 18px;
  }

  .pack-modal-viewers {
    padding: 22px 12px 28px;
    border-right: 0;
    border-top: 1px solid var(--color-line);
  }

  .pack-viewer-stage {
    gap: 6px;
  }

  .pack-viewer-arrow {
    width: 32px;
    height: 32px;
  }

  .pack-viewer-caption {
    margin-inline: 38px;
  }
}
