/* Certificates (About page): text cards with a hover focus effect, and a
   zoom-out-of-the-card viewer. Behaviour lives in certificates.js. */

.cert-section { margin-top: 4.5rem; }
.cert-title {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin: 0 0 1.5rem;
  font-size: clamp(1.375rem, 2.4vw, 1.75rem);
  font-weight: 700;
  line-height: 1.2;
}
.cert-title::before {
  content: '';
  width: 0.375rem;
  height: 1.6rem;
  border-radius: 99px;
  background: var(--teal);
}

.cert-grid {
  --dim: brightness(.55);
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 17rem), 1fr));
  gap: 1rem;
}
html[data-theme="light"] .cert-grid { --dim: brightness(.9) saturate(.8); }

.cert-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  min-height: 7.5rem;
  padding: 1.125rem 1.25rem;
  font: inherit;
  text-align: left;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  cursor: pointer;
  box-shadow: var(--shadow-card);
  transition: transform .45s cubic-bezier(.22, 1, .36, 1), opacity .4s ease, filter .4s ease, border-color .3s ease;
}
.cert-card:focus-visible { outline: 2px solid var(--teal); outline-offset: 3px; }

/* Focus effect: only while the pointer is on a card (or it has keyboard focus) */
.cert-grid.is-focusing .cert-card:not(.is-focus) { opacity: .8; filter: var(--dim) blur(1.5px); }
.cert-card.is-focus { z-index: 2; transform: translateY(-0.375rem) scale(1.03); border-color: var(--teal); }

.cert-meta { display: flex; align-items: center; gap: 0.5rem; padding-right: 1.75rem; }
.cert-badge {
  font-size: 0.6875rem;
  letter-spacing: .04em;
  color: var(--muted);
  background: var(--surface-2);
  border-radius: 0.1875rem;
  padding: 0.125rem 0.5rem;
}
.cert-year { font-size: 0.75rem; color: var(--teal); }
.cert-name { font-size: 1.0625rem; font-weight: 600; line-height: 1.3; }
.cert-issuer { margin-top: auto; font-size: 0.8125rem; color: var(--muted); }
.cert-ico { position: absolute; top: 1.125rem; right: 1.125rem; color: var(--muted); transition: color .3s ease; }
.cert-card.is-focus .cert-ico { color: var(--teal); }

/* Viewer */
.cert-lightbox {
  position: fixed;
  inset: 0;
  z-index: 15000;
  display: flex;
  align-items: center;
  justify-content: center;
  visibility: hidden;
  opacity: 0;
  transition: opacity .3s ease, visibility 0s linear .55s;
}
.cert-lightbox.is-open { visibility: visible; opacity: 1; transition: opacity .3s ease, visibility 0s; }
.cert-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(6, 10, 12, .74);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
}
.cert-box {
  position: relative;
  margin: 0;
  width: min(92vw, 62rem, calc((100vh - 9rem) * 1.476));    /* fallback */
  width: min(92vw, 62rem, calc((100dvh - 9rem) * 1.476));
  transition: transform .55s cubic-bezier(.22, 1, .36, 1), opacity .35s ease;
}
.cert-box img {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 1938 / 1313;
  object-fit: contain;
  background: var(--surface);
  border-radius: 0.5rem;
  box-shadow: 0 1.5rem 4rem rgba(0, 0, 0, .5);
}
.cert-box figcaption {
  margin-top: 0.875rem;
  text-align: center;
  color: #E7ECE9;
  font-size: 0.875rem;
  line-height: 1.5;
}
.cert-box figcaption strong { display: block; font-size: 1rem; font-weight: 600; }
.cert-box figcaption span { color: #A9B7B3; }
.cert-close {
  position: absolute;
  top: max(1.25rem, env(safe-area-inset-top, 0px));
  right: max(1.25rem, env(safe-area-inset-right, 0px));
  width: 2.5rem;
  height: 2.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #E7ECE9;
  background: rgba(16, 23, 26, .8);
  border: 1px solid #3A4A4F;
  border-radius: 50%;
  cursor: pointer;
  transition: border-color .2s ease, color .2s ease;
}
@media (hover: hover) { .cert-close:hover { border-color: #3EC9A7; color: #3EC9A7; } }
.cert-close:focus-visible { border-color: #3EC9A7; color: #3EC9A7; outline: none; }
/* touch: invisible 44x44px tap area around the close button */
@media (pointer: coarse) { .cert-close::after { content: ''; position: absolute; inset: -0.25rem; } }

/* short screens (landscape phones): give the certificate more of the height */
@media (max-height: 33.75rem) {
  .cert-box { width: min(92vw, 62rem, calc((100vh - 6rem) * 1.476)); width: min(92vw, 62rem, calc((100dvh - 6rem) * 1.476)); }
  .cert-box figcaption { margin-top: 0.5rem; }
}

@media (prefers-reduced-motion: reduce) {
  .cert-card, .cert-lightbox, .cert-box { transition: none; }
}