/* ────────────────────────────────────────────────────────────────────────────
 * مكتبة ليبيا الطيبة — Certificate UI styles
 * ----------------------------------------------------------------------------
 * Covers:
 *   1. .cert-banner             — celebration overlay shown in the reader
 *   2. .cert-confetti           — falling confetti pieces
 *   3. .cert-page-*             — full /certificates.html page layout
 *   4. .cert-card                — individual certificate card
 *   5. .profile-certificates    — section embedded in /profile.html
 *
 * Palette mirrors the rest of the library:
 *   parchment #FAF6EE · ink #0F1B2D · gold #B89968 · red #B1373F
 * ──────────────────────────────────────────────────────────────────────────── */

:root {
  --cert-parchment: #FAF6EE;
  --cert-ink:       #0F1B2D;
  --cert-gold:      #B89968;
  --cert-gold-deep: #94794F;
  --cert-gold-soft: rgba(184, 153, 104, 0.12);
  --cert-border:    rgba(184, 153, 104, 0.30);
  --cert-red:       #B1373F;
  --cert-muted:     #5a6a7a;
  --cert-shadow:    0 14px 40px rgba(15, 27, 45, 0.18);
  --cert-shadow-lg: 0 24px 60px rgba(15, 27, 45, 0.28);
}

[data-theme="dark"] {
  --cert-parchment: #1a2a3d;
  --cert-ink:       #FAF6EE;
  --cert-gold-soft: rgba(184, 153, 104, 0.18);
  --cert-border:    rgba(184, 153, 104, 0.25);
  --cert-muted:     #9aacb8;
}

/* ═══════════════════════════════════════════════════════════════════════════
 * 1. CELEBRATION BANNER (reader.html)
 * ═══════════════════════════════════════════════════════════════════════════ */
.cert-banner-backdrop {
  position: fixed;
  inset: 0;
  background: radial-gradient(ellipse at center,
              rgba(15, 27, 45, 0.65) 0%,
              rgba(15, 27, 45, 0.85) 100%);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  padding: 1.5rem;
  animation: certFadeIn .35s ease-out;
}
.cert-banner-backdrop.open { display: flex; }

@keyframes certFadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.cert-banner {
  position: relative;
  max-width: 560px;
  width: 100%;
  background:
    radial-gradient(ellipse at 30% 0%, rgba(184, 153, 104, 0.18), transparent 60%),
    linear-gradient(180deg, #FBF7EA 0%, #F4EAD4 100%);
  border: 1.5px solid var(--cert-gold);
  border-radius: 28px;
  padding: 3rem 2.5rem 2.5rem;
  text-align: center;
  font-family: 'Aref Ruqaa', 'Amiri', 'Cairo', serif;
  color: var(--cert-ink);
  box-shadow: var(--cert-shadow-lg),
              inset 0 0 0 1px rgba(255, 255, 255, 0.5),
              inset 0 0 60px rgba(184, 153, 104, 0.08);
  direction: rtl;
  animation: certPop .55s cubic-bezier(.18,.89,.32,1.28);
}
@keyframes certPop {
  from { transform: scale(0.7) translateY(40px); opacity: 0; }
  to   { transform: scale(1)   translateY(0);    opacity: 1; }
}

/* Decorative gold corners on the banner */
.cert-banner::before,
.cert-banner::after {
  content: '';
  position: absolute;
  width: 50px; height: 50px;
  border: 1.5px solid var(--cert-gold);
  pointer-events: none;
}
.cert-banner::before {
  top: 16px; right: 16px;
  border-bottom: 0; border-left: 0;
  border-top-right-radius: 18px;
}
.cert-banner::after {
  bottom: 16px; left: 16px;
  border-top: 0; border-right: 0;
  border-bottom-left-radius: 18px;
}

.cert-banner-trophy {
  font-size: 4rem;
  line-height: 1;
  margin-bottom: 1rem;
  animation: certBounce 2.5s ease-in-out infinite;
  filter: drop-shadow(0 6px 12px rgba(184, 153, 104, 0.4));
}
@keyframes certBounce {
  0%, 100% { transform: translateY(0) rotate(-3deg); }
  50%      { transform: translateY(-8px) rotate(3deg); }
}

.cert-banner-title {
  font-family: 'Aref Ruqaa', serif;
  font-size: 2rem;
  font-weight: 700;
  color: var(--cert-gold-deep);
  margin: 0 0 0.5rem;
  letter-spacing: 0.5px;
}

.cert-banner-subtitle {
  font-family: 'Amiri', serif;
  font-style: italic;
  font-size: 1.05rem;
  color: var(--cert-muted);
  margin: 0 0 1rem;
}

.cert-banner-book {
  font-family: 'Aref Ruqaa', serif;
  font-size: 1.2rem;
  color: var(--cert-ink);
  margin: 0.5rem 0 1.75rem;
  padding: 0.75rem 1rem;
  background: rgba(255, 255, 255, 0.45);
  border-top: 1px solid var(--cert-border);
  border-bottom: 1px solid var(--cert-border);
}

.cert-banner-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.85rem;
  justify-content: center;
}

.cert-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.85rem 1.6rem;
  border-radius: 14px;
  font-family: 'Aref Ruqaa', 'Cairo', serif;
  font-size: 1rem;
  font-weight: 700;
  border: 0;
  cursor: pointer;
  transition: transform .2s, box-shadow .2s, filter .2s;
  text-decoration: none;
}
.cert-btn-gold {
  background: linear-gradient(135deg, var(--cert-gold), #D4AF37);
  color: #1A0F08;
  box-shadow: 0 6px 18px rgba(184, 153, 104, 0.4);
}
.cert-btn-gold:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 26px rgba(184, 153, 104, 0.55);
  filter: brightness(1.05);
}
.cert-btn-ghost {
  background: transparent;
  color: var(--cert-muted);
  border: 1px solid var(--cert-border);
}
.cert-btn-ghost:hover {
  color: var(--cert-ink);
  border-color: var(--cert-gold);
}
.cert-btn[disabled] {
  opacity: 0.55;
  cursor: wait;
  transform: none;
}

.cert-banner-close {
  position: absolute;
  top: 14px;
  left: 14px;
  width: 36px; height: 36px;
  background: transparent;
  border: 0;
  border-radius: 50%;
  font-size: 1.3rem;
  color: var(--cert-muted);
  cursor: pointer;
  transition: background .2s, color .2s;
}
.cert-banner-close:hover {
  background: var(--cert-gold-soft);
  color: var(--cert-ink);
}

/* ═══════════════════════════════════════════════════════════════════════════
 * 2. CONFETTI
 * ═══════════════════════════════════════════════════════════════════════════ */
.cert-confetti-layer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 10000;
}
.cert-confetti-piece {
  position: absolute;
  top: -20px;
  width: 10px; height: 14px;
  opacity: 0.9;
  border-radius: 2px;
  animation-name: certConfettiFall;
  animation-timing-function: cubic-bezier(.36,.07,.51,.96);
  animation-fill-mode: forwards;
}
@keyframes certConfettiFall {
  0% {
    transform: translate3d(0, -20px, 0) rotate(0deg);
    opacity: 1;
  }
  100% {
    transform: translate3d(var(--cert-drift, 60px), 105vh, 0) rotate(720deg);
    opacity: 0;
  }
}

/* ═══════════════════════════════════════════════════════════════════════════
 * 3. /certificates.html PAGE
 * ═══════════════════════════════════════════════════════════════════════════ */
.cert-page-body {
  background: var(--cert-parchment);
  color: var(--cert-ink);
  font-family: 'Cairo', system-ui, sans-serif;
  direction: rtl;
  min-height: 100vh;
  line-height: 1.6;
  margin: 0;
}

.cert-page-hero {
  background: linear-gradient(135deg, #2a1810 0%, #3a2412 40%, #1a0f08 100%);
  color: #FAF6EE;
  padding: 3.5rem 1.5rem 4rem;
  text-align: center;
  position: relative;
  overflow: hidden;
  border-bottom: 1px solid rgba(184, 153, 104, 0.4);
}
.cert-page-hero::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image: radial-gradient(circle, rgba(184, 153, 104, 0.10) 1px, transparent 1px);
  background-size: 22px 22px;
  pointer-events: none;
}
.cert-page-hero-inner {
  position: relative;
  z-index: 1;
  max-width: 720px;
  margin: 0 auto;
}
.cert-page-trophy {
  display: inline-block;
  font-size: 3.2rem;
  margin-bottom: 0.5rem;
  filter: drop-shadow(0 6px 14px rgba(184, 153, 104, 0.55));
}
.cert-page-title {
  font-family: 'Aref Ruqaa', 'Amiri', serif;
  font-size: 2.4rem;
  font-weight: 700;
  margin: 0.25rem 0 0.5rem;
  color: #FAF6EE;
  letter-spacing: 0.5px;
}
.cert-page-subtitle {
  font-family: 'Amiri', serif;
  font-style: italic;
  font-size: 1.1rem;
  color: rgba(250, 246, 238, 0.75);
  margin: 0;
}
.cert-page-count {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 1rem;
  padding: 0.45rem 1rem;
  background: rgba(184, 153, 104, 0.18);
  border: 1px solid rgba(184, 153, 104, 0.35);
  border-radius: 999px;
  font-family: 'Cairo', sans-serif;
  font-size: 0.85rem;
  color: var(--cert-gold);
}

.cert-page-container {
  max-width: 1100px;
  margin: -2rem auto 0;
  padding: 0 1.5rem 4rem;
  position: relative;
}

.cert-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1.5rem;
}

/* ═══════════════════════════════════════════════════════════════════════════
 * 4. CERTIFICATE CARD
 * ═══════════════════════════════════════════════════════════════════════════ */
.cert-card {
  position: relative;
  background:
    radial-gradient(ellipse at 30% 0%, rgba(184, 153, 104, 0.10), transparent 60%),
    linear-gradient(180deg, #FBF7EA 0%, #F4EAD4 100%);
  border: 1px solid var(--cert-border);
  border-radius: 18px;
  padding: 1.5rem 1.25rem 1.25rem;
  box-shadow: var(--cert-shadow);
  transition: transform .25s, box-shadow .25s, border-color .25s;
  overflow: hidden;
}
.cert-card:hover {
  transform: translateY(-4px);
  border-color: var(--cert-gold);
  box-shadow: var(--cert-shadow-lg);
}

/* Gold ribbon at top */
.cert-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 4px;
  background: linear-gradient(90deg, var(--cert-gold-deep), var(--cert-gold), var(--cert-gold-deep));
}

.cert-card-seal {
  width: 56px; height: 56px;
  border-radius: 50%;
  background: radial-gradient(circle, #FFFDF6 30%, rgba(184, 153, 104, 0.10) 80%);
  border: 1.5px solid var(--cert-red);
  display: flex; align-items: center; justify-content: center;
  font-family: 'Aref Ruqaa', serif;
  font-size: 1.85rem;
  color: var(--cert-red);
  margin: 0 auto 0.75rem;
  position: relative;
  box-shadow: 0 4px 12px rgba(177, 55, 63, 0.18);
}
.cert-card-seal::after {
  content: '';
  position: absolute;
  inset: 4px;
  border: 0.6px solid var(--cert-red);
  border-radius: 50%;
}

.cert-card-label {
  text-align: center;
  font-family: 'Cairo', sans-serif;
  font-size: 0.75rem;
  color: var(--cert-gold-deep);
  letter-spacing: 1.5px;
  margin: 0 0 0.25rem;
}

.cert-card-title {
  font-family: 'Aref Ruqaa', 'Amiri', serif;
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--cert-ink);
  text-align: center;
  margin: 0 0 0.4rem;
  line-height: 1.4;
  min-height: 3.4em;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.cert-card-author {
  font-family: 'Amiri', serif;
  font-style: italic;
  font-size: 0.92rem;
  color: var(--cert-muted);
  text-align: center;
  margin: 0 0 0.85rem;
  min-height: 1.4em;
}

.cert-card-divider {
  width: 60%;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--cert-gold) 50%, transparent);
  margin: 0.5rem auto 0.85rem;
}

.cert-card-date {
  text-align: center;
  font-family: 'Cairo', sans-serif;
  font-size: 0.85rem;
  color: var(--cert-muted);
  margin: 0 0 1rem;
}
.cert-card-date strong {
  color: var(--cert-ink);
  font-weight: 600;
}

.cert-card-actions {
  display: flex;
  gap: 0.5rem;
  justify-content: center;
}

.cert-card-id {
  position: absolute;
  bottom: 6px;
  left: 10px;
  font-family: 'Cairo', monospace;
  font-size: 0.62rem;
  color: rgba(15, 27, 45, 0.35);
  letter-spacing: 0.5px;
}

/* ═══════════════════════════════════════════════════════════════════════════
 * EMPTY STATE
 * ═══════════════════════════════════════════════════════════════════════════ */
.cert-empty {
  text-align: center;
  padding: 4rem 1.5rem;
  max-width: 520px;
  margin: 0 auto;
}
.cert-empty-icon {
  font-size: 4rem;
  margin-bottom: 1rem;
  opacity: 0.55;
}
.cert-empty-title {
  font-family: 'Aref Ruqaa', serif;
  font-size: 1.5rem;
  color: var(--cert-ink);
  margin: 0 0 0.5rem;
}
.cert-empty-sub {
  font-family: 'Amiri', serif;
  font-style: italic;
  color: var(--cert-muted);
  margin: 0 0 1.5rem;
  font-size: 1.05rem;
}

.cert-loading {
  text-align: center;
  padding: 3rem 1.5rem;
  font-family: 'Amiri', serif;
  font-style: italic;
  color: var(--cert-muted);
}
.cert-loading::after {
  content: '';
  display: inline-block;
  width: 14px; height: 14px;
  margin-right: 0.5rem;
  border: 2px solid var(--cert-border);
  border-top-color: var(--cert-gold);
  border-radius: 50%;
  animation: certSpin 0.8s linear infinite;
  vertical-align: middle;
}
@keyframes certSpin { to { transform: rotate(360deg); } }

/* ═══════════════════════════════════════════════════════════════════════════
 * 5. /profile.html SECTION
 * ═══════════════════════════════════════════════════════════════════════════ */
.profile-certificates {
  margin: 2rem 0;
  padding: 1.75rem 1.5rem;
  background:
    radial-gradient(ellipse at 30% 0%, rgba(184, 153, 104, 0.10), transparent 60%),
    linear-gradient(180deg, #FBF7EA 0%, #F4EAD4 100%);
  border: 1px solid var(--cert-border);
  border-radius: 18px;
  text-align: center;
  position: relative;
  overflow: hidden;
}
.profile-certificates::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--cert-gold-deep), var(--cert-gold), var(--cert-gold-deep));
}
.profile-certificates h2 {
  font-family: 'Aref Ruqaa', 'Amiri', serif;
  font-size: 1.4rem;
  color: var(--cert-gold-deep);
  margin: 0 0 0.5rem;
}
.profile-certificates p {
  font-family: 'Amiri', serif;
  color: var(--cert-muted);
  margin: 0 0 1.25rem;
  font-style: italic;
}
.profile-certificates .btn-gold {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.7rem 1.5rem;
  background: linear-gradient(135deg, var(--cert-gold), #D4AF37);
  color: #1A0F08;
  border-radius: 12px;
  font-family: 'Aref Ruqaa', serif;
  font-weight: 700;
  text-decoration: none;
  box-shadow: 0 6px 18px rgba(184, 153, 104, 0.35);
  transition: transform .2s, box-shadow .2s;
}
.profile-certificates .btn-gold:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 26px rgba(184, 153, 104, 0.5);
}

/* ═══════════════════════════════════════════════════════════════════════════
 * RESPONSIVE
 * ═══════════════════════════════════════════════════════════════════════════ */
@media (max-width: 560px) {
  .cert-page-hero { padding: 2.5rem 1rem 3rem; }
  .cert-page-title { font-size: 1.8rem; }
  .cert-banner { padding: 2.25rem 1.5rem 1.75rem; }
  .cert-banner-title { font-size: 1.5rem; }
  .cert-banner-trophy { font-size: 3rem; }
  .cert-grid { grid-template-columns: 1fr; }
}
