/* ── Certifications ───────────────────────────────────────────────────
   A page of certificate cards: preview, details, view and download. Uses
   the site's existing tokens, card treatment and reveal animation, so it
   sits beside the product pages rather than looking bolted on. */

.certs { padding-bottom: var(--space-8); }

.certs__grid {
  display: grid;
  gap: var(--space-5);
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr));
}

.certs__state:empty { display: none; }
.certs__state { display: grid; gap: var(--space-4); justify-items: start; padding: var(--space-6) 0; color: var(--text-secondary); }
.certs__error { color: var(--red-text); }

.cert {
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: var(--surface-panel);
  border: 1px solid var(--surface-line);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

/* Certificates are portrait documents: a tall frame shows them whole. */
.cert__media {
  position: relative;
  /* Certificates are portrait documents. */
  aspect-ratio: 3 / 4;
  display: grid;
  place-items: center;
  padding: var(--space-4);
  background: var(--surface-raised);
  border-bottom: 1px solid var(--surface-line);
}
.cert__media img { max-width: 100%; max-height: 100%; width: auto; height: auto; object-fit: contain; }

/* A PDF with no cover picture: a document tile rather than an empty frame. */
.cert__doc { position: absolute; inset: 0; display: grid; gap: var(--space-2); place-content: center; justify-items: center; color: var(--text-muted); }

/* A PDF with no cover image gets a document tile, never an empty frame. */
.cert__doc { display: grid; gap: var(--space-2); justify-items: center; color: var(--text-muted); }
.cert__doc span { font-size: var(--size-xs); letter-spacing: var(--tracking-wide); }

.cert__body { display: flex; flex-direction: column; gap: var(--space-3); padding: var(--space-5); flex: 1; }
.cert__title { font-size: var(--size-lg); line-height: 1.15; }
.cert__issuer { color: var(--red-text); font-size: var(--size-sm); }
.cert__desc { color: var(--text-secondary); font-size: var(--size-sm); }

.cert__details { display: grid; gap: var(--space-2); margin-top: auto; }
.cert__details:empty { display: none; }
.cert__detail { display: grid; grid-template-columns: minmax(0, 8.5rem) minmax(0, 1fr); gap: var(--space-3); font-size: var(--size-sm); }
.cert__detail dt { color: var(--text-muted); text-transform: uppercase; letter-spacing: var(--tracking-wide); font-size: var(--size-xs); align-self: center; }
.cert__detail dd { color: var(--text-primary); overflow-wrap: anywhere; }

.cert__actions { display: flex; flex-wrap: wrap; gap: var(--space-3); padding-top: var(--space-2); }
.cert__actions .btn { flex: 1 1 auto; text-align: center; justify-content: center; }

/* ── Larger view, over the page ── */
.certview {
  position: fixed; inset: 0; z-index: 1200;
  display: grid; place-items: center;
  padding: var(--space-4);
  background: rgba(4, 5, 6, 0.72);
  backdrop-filter: blur(3px);
}
.certview__dialog {
  display: flex; flex-direction: column;
  width: min(1000px, 100%); height: min(92vh, 100%);
  background: var(--surface-panel);
  border: 1px solid var(--surface-line);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.certview__head {
  display: flex; align-items: center; justify-content: space-between; gap: var(--space-4);
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--surface-line);
}
.certview__title { font-size: var(--size-base); line-height: 1.2; }
.certview__issuer { color: var(--text-secondary); font-size: var(--size-xs); margin-top: 4px; }
.certview__tools { display: flex; align-items: center; gap: var(--space-2); flex: none; }
.certview__close {
  width: 38px; height: 38px; flex: none;
  border: 1px solid var(--surface-line); border-radius: 50%;
  color: var(--text-primary); background: var(--surface-raised);
}
.certview__close:hover { border-color: var(--red); color: var(--red-text); }
.certview__close:focus-visible, .certview__tools .btn:focus-visible { outline: 2px solid var(--red); outline-offset: 2px; }

.certview__body { flex: 1; min-height: 0; display: grid; place-items: center; background: var(--surface-raised); }
.certview__frame { width: 100%; height: 100%; border: 0; }
.certview__image { max-width: 100%; max-height: 100%; object-fit: contain; }

@media (max-width: 720px) {
  .certview { padding: 0; }
  .certview__dialog { height: 100%; width: 100%; border: 0; border-radius: 0; }
  .certview__head { flex-wrap: wrap; }
  .certview__tools { width: 100%; justify-content: flex-end; }
  .cert__detail { grid-template-columns: minmax(0, 1fr); gap: 2px; }
}

@media (prefers-reduced-motion: reduce) {
  .certview { backdrop-filter: none; }
}
