/* ==========================================================================
   Component · Download dialog
   A real <dialog>, so the platform handles Escape, the backdrop and focus.
   ========================================================================== */

.download-modal {
  /* A <dialog> centres itself with `margin: auto`, which the global reset in
     base.css sets to 0. Restoring it here rather than exempting dialog from
     the reset keeps the reset simple. */
  margin: auto;
  width: min(44rem, calc(100vw - 2rem));
  max-height: min(90dvh, 48rem);
  padding: 0;
  border: 1px solid var(--color-border);
  border-radius: 28px;
  background: var(--color-menu-bg);
  color: var(--color-text-secondary);
  overflow: auto;
  overscroll-behavior: contain;
}

.download-modal::backdrop {
  background: rgba(0, 0, 0, 0.62);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
}

:root[data-theme="light"] .download-modal::backdrop {
  background: rgba(0, 0, 0, 0.34);
}

.download-modal[open] {
  animation: download-modal-in var(--duration-fast) var(--ease-spring);
}

@keyframes download-modal-in {
  from { opacity: 0; transform: translateY(10px) scale(0.985); }
  to   { opacity: 1; transform: none; }
}

.download-modal__panel {
  position: relative;
  padding: clamp(1.75rem, 1.25rem + 2vw, 2.75rem);
  text-align: center;
}

.download-modal__close {
  position: absolute;
  top: 1rem;
  inset-inline-end: 1rem;
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 1px solid var(--color-hairline);
  border-radius: 50%;
  background: transparent;
  color: var(--color-text-secondary);
  cursor: pointer;
  transition:
    background-color var(--duration-fast) var(--ease-gentle),
    color var(--duration-fast) var(--ease-gentle);
}

.download-modal__close:hover {
  background: var(--color-tile-hover);
  color: var(--color-text-primary);
}

.download-modal__close svg {
  width: 16px;
  height: 16px;
}

.download-modal__icon {
  width: 72px;
  margin-inline: auto;
}

.download-modal__title {
  margin-top: 1rem;
  font-size: var(--text-card-title);
  line-height: 1.15;
}

.download-modal__lede {
  margin-top: 0.6rem;
  margin-inline: auto;
  max-width: 40ch;
  font-size: var(--text-caption);
  color: var(--color-text-tertiary);
  line-height: 1.55;
}

/* ---- The two store cards ------------------------------------------------- */

.download-modal__grid {
  margin-top: 1.75rem;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
}

.download-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.9rem;
  padding: 1.25rem 1rem;
  border: 1px solid var(--color-border);
  border-radius: 20px;
  background: var(--color-surface);
}

.download-card__title {
  font-size: var(--text-body);
  font-weight: 600;
  line-height: 1.2;
}

.download-card__note {
  margin-top: 0.3rem;
  font-size: 0.75rem;
  color: var(--color-text-tertiary);
  line-height: 1.4;
}

.download-card__badge {
  display: block;
  width: min(100%, 11rem);
  transition: transform var(--duration-fast) var(--ease-spring);
}

.download-card__badge:hover {
  transform: scale(1.03);
}

/* The QR is for the two devices where a store badge is least useful: a laptop
   and a television. It is decorative — the badge above it is the real link. */
.download-card__qr {
  width: 108px;
  padding: 8px;
  border-radius: 10px;
  background: #fff;
}

.download-card__qr svg {
  width: 100%;
  height: auto;
  display: block;
}

.download-card__scan {
  font-size: 0.6875rem;
  color: var(--color-text-tertiary);
  letter-spacing: 0.02em;
}

.download-modal__fineprint {
  margin-top: 1.5rem;
  font-size: 0.75rem;
  color: var(--color-text-tertiary);
  line-height: 1.5;
  text-wrap: pretty;
}

/* On a phone the QR codes are pointless — the phone is the target device. */
@media (max-width: 34em) {
  .download-modal__grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .download-card__qr,
  .download-card__scan {
    display: none;
  }

  .download-card {
    flex-direction: row;
    justify-content: space-between;
    text-align: start;
    gap: 1rem;
  }

  .download-card__badge {
    width: 9rem;
    flex: 0 0 auto;
  }
}

@media (prefers-reduced-motion: reduce) {
  .download-modal[open] { animation: none; }
  .download-card__badge { transition: none; }
}
