main {
  position: relative;
  z-index: 1;
}

.cert-hero {
  min-height: 44vh;
  padding: 8.5rem 3rem 2.5rem;
  display: flex;
  align-items: flex-end;
}

.cert-hero-inner {
  max-width: 1100px;
  margin: 0 auto;
  width: 100%;
}

.cert-title {
  font-family: "Rajdhani", sans-serif;
  font-size: clamp(2.2rem, 6.2vw, 5rem);
  font-weight: 700;
  line-height: 1.02;
  letter-spacing: 0.01em;
  color: var(--white);
}

.cert-sub {
  margin-top: 1.2rem;
  max-width: 620px;
  font-size: 1rem;
  line-height: 1.78;
  color: var(--muted);
}

.cert-gallery {
  padding: 1.5rem 3rem 7rem;
}

.cert-gallery-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 1.2rem 0.3rem;
}

.cert-carousel-head {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.5rem;
  margin-bottom: 1.8rem;
}

.cert-carousel-head .section-title {
  margin-bottom: 0;
}

.cert-carousel-note {
  color: var(--muted);
  font-family: "JetBrains Mono", monospace;
  font-size: 0.78rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

/* Hint above the carousel: a plain muted caption (no border or fill, so
   it doesn't read as a button). */
.cert-hint {
  margin: 0;
  text-align: center;
  color: var(--muted);
  font-family: "JetBrains Mono", monospace;
  font-size: 0.72rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.cert-carousel-shell {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  align-items: center;
  margin-top: 5.4rem;
}

.scene {
  position: relative;
  width: 100%;
  height: min(30vh, 240px);
  margin-bottom: 2.1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: visible;
  perspective: 1000px;
  /* Let the browser handle vertical scrolling only, so horizontal swipes
     reach the carousel's touch handlers in certifications.js. */
  touch-action: pan-y;
}

.carousel {
  position: relative;
  width: min(145px, 28vw);
  height: min(200px, 24vh);
  transform-style: preserve-3d;
  transition: transform 0.65s ease;
  will-change: transform;
}

.carousel-item {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0.35rem;
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
  border: 1px solid rgba(56, 189, 248, 0.2);
  background: var(--cert-card-bg);
  transform-style: preserve-3d;
  box-shadow: var(--surface-shadow);
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
  transition:
    opacity 0.35s ease,
    filter 0.35s ease,
    border-color 0.35s ease,
    box-shadow 0.35s ease,
    transform 0.65s ease;
}

/* Until certifications.js has placed the cards on the ring and added
   .is-ready, skip transitions: otherwise the cards animate from their
   unpositioned state (stacked, small) out to the ring on page load. */
.carousel:not(.is-ready),
.carousel:not(.is-ready) .carousel-item {
  transition: none;
}

.cert-slide {
  position: absolute;
}

.cert-slide img {
  width: 100%;
  height: calc(100% - 1.65rem);
  object-fit: contain;
  border: 1px solid rgba(56, 189, 248, 0.18);
  background: var(--control-bg);
  padding: 0.35rem;
}

.cert-slide figcaption {
  text-align: center;
  color: var(--text);
  font-family: "Rajdhani", sans-serif;
  font-size: 0.68rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.cert-slide.is-active {
  border-color: rgba(56, 189, 248, 0.7);
  box-shadow:
    var(--surface-shadow),
    0 0 26px rgba(56, 189, 248, 0.32);
}

.cert-fallback {
  width: 100%;
  height: calc(100% - 2.35rem);
  border: 1px solid rgba(56, 189, 248, 0.22);
  display: grid;
  place-items: center;
  font-family: "JetBrains Mono", monospace;
  color: var(--muted);
  font-size: 0.8rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.cert-nav {
  min-width: 72px;
  height: 34px;
  padding: 0 0.75rem;
  border: 1px solid var(--accent);
  background: var(--panel-bg);
  color: var(--accent);
  font-family: "JetBrains Mono", monospace;
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  line-height: 1;
  cursor: pointer;
  transition:
    transform 0.2s ease,
    box-shadow 0.2s ease,
    background 0.2s ease,
    color 0.2s ease;
}

.cert-nav:hover {
  background: var(--accent);
  color: var(--bg);
  transform: translateY(-2px);
  box-shadow: 0 0 20px var(--glow);
}

.cert-controls {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.45rem;
  margin-top: 1.85rem;
}

/* "01 / 16" position counter between Prev and Next. tabular-nums + a
   min-width keep the buttons from shifting as the number changes. */
.cert-counter {
  min-width: 5.5rem;
  padding: 0 0.6rem;
  text-align: center;
  color: var(--muted);
  font-family: "JetBrains Mono", monospace;
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.cert-counter__current {
  color: var(--accent);
  font-weight: 700;
}

.cert-actions {
  margin-top: 1.8rem;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.9rem;
  flex-wrap: wrap;
}

/* On this page "My Resume" sits in the same row as "See Projects", so it
   takes .btn-ghost's normal colors instead of the muted ones styles.css
   gives .btn-ghost.hero-resume-btn for the index.html hero. */
.cert-actions .btn-ghost.hero-resume-btn {
  border-color: var(--accent);
  color: var(--text);
}
.cert-actions .btn-ghost.hero-resume-btn:hover {
  color: var(--accent);
}

.cert-lightbox {
  position: fixed;
  inset: 0;
  z-index: 1300;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.cert-lightbox.is-open {
  display: flex;
}

.cert-lightbox__backdrop {
  position: absolute;
  inset: 0;
  background: var(--modal-backdrop);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
}

.cert-lightbox__dialog {
  position: relative;
  z-index: 1;
  width: min(900px, 94vw);
  max-height: 90vh;
  background: var(--cert-card-bg);
  border: 1px solid var(--border);
  box-shadow:
    var(--surface-shadow-strong),
    0 0 28px rgba(56, 189, 248, 0.2);
  padding: 1rem;
}

.cert-lightbox__image {
  width: 100%;
  max-height: calc(90vh - 2rem);
  object-fit: contain;
  display: block;
  border: 1px solid rgba(56, 189, 248, 0.25);
  background: var(--control-bg);
}

.cert-lightbox__description {
  margin-top: 0.8rem;
  padding: 0.7rem 0.85rem;
  border: 1px solid var(--border);
  background: var(--chip-bg);
  color: var(--text);
  font-family: "Syne", sans-serif;
  font-size: 0.92rem;
  line-height: 1.7;
}

.cert-lightbox__close {
  position: absolute;
  top: 0.55rem;
  right: 0.55rem;
  width: 34px;
  height: 34px;
  border: 1px solid rgba(56, 189, 248, 0.55);
  background: var(--control-bg);
  color: var(--accent);
  font-size: 1.35rem;
  line-height: 1;
  cursor: pointer;
}

.cert-lightbox__close:hover {
  background: var(--accent);
  color: var(--bg);
}

@media (max-width: 900px) {
  .cert-hero {
    padding: 8rem 1.25rem 2rem;
  }

  .cert-gallery {
    padding: 1rem 1.25rem 5.2rem;
  }

  .cert-gallery-inner {
    padding: 1rem 0;
  }

  .cert-carousel-head {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.45rem;
  }

  .cert-carousel-shell {
    gap: 0.7rem;
    margin-top: 4.2rem;
  }

  .cert-nav {
    min-width: 88px;
    height: 36px;
    font-size: 0.76rem;
  }

  .scene {
    height: min(28vh, 210px);
    margin-bottom: 3.2rem;
    perspective: 900px;
  }

  .carousel {
    width: min(132px, 48vw);
    height: min(182px, 22vh);
  }

  .carousel-item {
    padding: 0.3rem;
  }

  .cert-controls {
    margin-top: 1.6rem;
  }

  /* Stack the three buttons, all as wide as the widest one. */
  .cert-actions {
    margin-top: 2.2rem;
    flex-direction: column;
    align-items: stretch;
    width: fit-content;
    margin-inline: auto;
    text-align: center;
  }

  /* styles.css hides .hero-resume-btn at this width (the navbar's Resume
     button replaces it on index.html); on this page it stays as the third
     stacked button. */
  .cert-actions .hero-resume-btn {
    display: inline-flex;
    justify-content: center;
  }
}

@media (max-width: 560px) {
  .cert-title {
    line-height: 1.08;
  }

  .cert-sub {
    font-size: 0.95rem;
  }

  .cert-slide figcaption {
    font-size: 0.62rem;
  }

  .cert-lightbox__description {
    font-size: 0.87rem;
    line-height: 1.65;
    margin-top: 0.7rem;
    padding: 0.62rem 0.7rem;
  }
}
