:root {
  /* Palet gesampled uit het HHS-logo */
  --ink: #1d1d1b;
  --orange: #f08000;
  --orange-deep: #e03c20;
  --green: #6aab58;
  --green-dark: #3f7a33;
  --green-night: #24451e;
  --blue: #62aed6;
  --beige: #e0d0c0;
  --paper: #fdfbf5;
  --muted: #6b6b64;
  --paper-shadow: 0 12px 40px rgba(20, 40, 16, 0.3);
  --radius: 18px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
  font-family: "Roboto", system-ui, sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at 20% 15%, rgba(240, 128, 0, 0.14), transparent 45%),
    radial-gradient(circle at 85% 80%, rgba(98, 174, 214, 0.14), transparent 40%),
    linear-gradient(160deg, var(--green-dark), var(--green-night));
  min-height: 100vh;
}

#confetti {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 50;
}

#app {
  max-width: 560px;
  margin: 0 auto;
  padding: 24px 16px 56px;
}

/* ---------- states ---------- */

.state {
  min-height: 70vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  color: var(--paper);
  text-align: center;
}

.spinner {
  width: 46px;
  height: 46px;
  border: 4px solid rgba(253, 251, 245, 0.25);
  border-top-color: var(--orange);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.error-card {
  background: var(--paper);
  color: var(--ink);
  border-radius: var(--radius);
  padding: 36px 28px;
  box-shadow: var(--paper-shadow);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  max-width: 400px;
}

.error-icon { font-size: 44px; }

.error-card h1 {
  font-family: "Oswald", sans-serif;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-size: 24px;
  color: var(--ink);
}

/* ---------- oorkonde ---------- */

.certificate {
  background: var(--paper);
  border-radius: var(--radius);
  box-shadow: var(--paper-shadow);
  padding: 10px;
  animation: rise 0.6s ease-out;
}

@keyframes rise {
  from { opacity: 0; transform: translateY(18px); }
  to   { opacity: 1; transform: translateY(0); }
}

.certificate-inner {
  border: 2px solid var(--orange);
  outline: 1px solid rgba(240, 128, 0, 0.4);
  outline-offset: 4px;
  border-radius: calc(var(--radius) - 8px);
  padding: 28px 20px 24px;
  text-align: center;
  background:
    radial-gradient(circle at 50% 0%, rgba(224, 208, 192, 0.25), transparent 55%);
}

.cert-logo {
  width: min(280px, 78%);
  display: block;
  margin: 0 auto;
}

.cert-title {
  font-family: "Oswald", sans-serif;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-size: clamp(38px, 10vw, 52px);
  line-height: 1.1;
  color: var(--ink);
  margin-top: 14px;
}

.cert-subtitle {
  font-family: "Roboto", sans-serif;
  font-style: italic;
  font-size: 16px;
  color: var(--orange-deep);
  margin-top: 2px;
}

.cert-photo-wrap {
  position: relative;
  width: min(220px, 55vw);
  margin: 22px auto 0;
}

.cert-photo {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: 50%;
  border: 5px solid var(--orange);
  box-shadow: 0 6px 18px rgba(20, 40, 16, 0.25);
  display: block;
}

.cert-photo-fallback {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 56px;
  background: #eef4ea;
}

.cert-seal {
  position: absolute;
  right: -6px;
  bottom: -2px;
  width: 26%;
  filter: drop-shadow(0 3px 6px rgba(20, 40, 16, 0.3));
}

.cert-awarded {
  margin-top: 22px;
  font-size: 14px;
  color: var(--muted);
}

.cert-team {
  font-family: "Oswald", sans-serif;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  font-size: clamp(28px, 8vw, 40px);
  color: var(--ink);
  margin-top: 4px;
  overflow-wrap: anywhere;
}

.cert-org {
  font-size: 15px;
  font-weight: 500;
  color: var(--green-dark);
  margin-top: 4px;
  overflow-wrap: anywhere;
}

.cert-stats {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-top: 24px;
}

.stat {
  flex: 1;
  max-width: 130px;
  background: #fff;
  border: 1px solid var(--beige);
  border-top: 4px solid var(--beige);
  border-radius: 12px;
  padding: 12px 6px;
}

.stat:nth-child(1) { border-top-color: var(--orange); }
.stat:nth-child(2) { border-top-color: var(--green); }
.stat:nth-child(3) { border-top-color: var(--blue); }

.stat dt {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted);
}

.stat dd {
  font-family: "Oswald", sans-serif;
  font-size: clamp(20px, 6vw, 26px);
  font-weight: 600;
  color: var(--ink);
  margin-top: 2px;
}

.cert-date {
  margin-top: 20px;
  font-size: 14px;
  color: var(--muted);
}

.cert-ranking {
  margin-top: 16px;
  font-size: 14px;
  line-height: 1.55;
  color: var(--muted);
}

.cert-ranking strong { color: var(--ink); }

.cert-footer {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-top: 18px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--orange-deep);
}

.cert-footer a {
  color: inherit;
  text-decoration: none;
}

.cert-footer a:hover { text-decoration: underline; }

.cert-footer-line {
  flex: 0 1 60px;
  height: 1px;
  background: rgba(240, 128, 0, 0.55);
}

/* ---------- delen ---------- */

.share-bar {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  margin-top: 22px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 0;
  border-radius: 999px;
  padding: 13px 22px;
  font-family: inherit;
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.btn:active { transform: scale(0.97); }

.btn svg { width: 20px; height: 20px; }

.btn-primary {
  background: linear-gradient(135deg, var(--orange), var(--orange-deep));
  color: #fff;
  box-shadow: 0 4px 14px rgba(224, 60, 32, 0.45);
}

.btn-primary:hover { box-shadow: 0 6px 18px rgba(224, 60, 32, 0.6); }

.btn-secondary {
  background: rgba(253, 251, 245, 0.14);
  color: var(--paper);
  border: 1px solid rgba(253, 251, 245, 0.45);
}

.btn-secondary:hover { background: rgba(253, 251, 245, 0.22); }

.error-card .btn-secondary {
  background: linear-gradient(135deg, var(--orange), var(--orange-deep));
  color: #fff;
  border: 0;
}

.share-links { display: flex; gap: 10px; }

.btn-icon {
  width: 48px;
  height: 48px;
  padding: 0;
  background: rgba(253, 251, 245, 0.14);
  color: var(--paper);
  border: 1px solid rgba(253, 251, 245, 0.45);
}

.btn-icon:hover { background: rgba(253, 251, 245, 0.22); }

/* ---------- galerij ---------- */

.gallery-section { margin-top: 36px; }

.gallery-section h3 {
  font-family: "Oswald", sans-serif;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 18px;
  color: var(--paper);
  text-align: center;
  margin-bottom: 14px;
}

.gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 10px;
}

.gallery-item {
  position: relative;
  margin: 0;
}

.gallery img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: 12px;
  border: 3px solid rgba(253, 251, 245, 0.9);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
  display: block;
}

.gallery-download {
  position: absolute;
  right: 9px;
  bottom: 9px;
  width: 38px;
  height: 38px;
  border: 0;
  border-radius: 50%;
  background: rgba(29, 29, 27, 0.65);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.15s ease;
}

.gallery-download:hover { background: var(--orange); }

.gallery-download:active { transform: scale(0.94); }

.gallery-download:disabled { opacity: 0.6; cursor: wait; }

.gallery-download svg { width: 18px; height: 18px; }

/* Downloadknop bij de teamfoto: linksonder, want de zegel zit rechtsonder */
.team-photo-download {
  left: 4px;
  bottom: 8px;
  right: auto;
  box-shadow: 0 2px 8px rgba(20, 40, 16, 0.3);
}

/* ---------- landelijk klassement ---------- */

.ranking-section { margin-top: 36px; }

.ranking-section h3 {
  font-family: "Oswald", sans-serif;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 18px;
  color: var(--paper);
  text-align: center;
}

.ranking-sub {
  text-align: center;
  font-size: 13px;
  color: rgba(253, 251, 245, 0.75);
  margin: 4px 0 14px;
}

.ranking-list {
  list-style: none;
  background: var(--paper);
  border-radius: var(--radius);
  box-shadow: var(--paper-shadow);
  padding: 6px 10px;
}

.ranking-list li {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 8px;
  border-bottom: 1px solid rgba(29, 29, 27, 0.07);
}

.ranking-list li:last-child { border-bottom: 0; }

.rank-pos {
  flex-shrink: 0;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: "Oswald", sans-serif;
  font-weight: 600;
  font-size: 15px;
  background: var(--beige);
  color: var(--ink);
}

.rank-1 { background: #f2c14e; }
.rank-2 { background: #d9d9d9; }
.rank-3 { background: #dfa06e; }

.rank-team {
  flex: 1;
  font-weight: 500;
  overflow-wrap: anywhere;
}

.rank-points {
  font-family: "Oswald", sans-serif;
  font-weight: 600;
  color: var(--green-dark);
}

.rank-me {
  background: rgba(240, 128, 0, 0.12);
  border-radius: 10px;
  border-bottom: 0;
}

.ranking-cta {
  margin-top: 24px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.ranking-cta p {
  font-family: "Oswald", sans-serif;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-size: 16px;
  color: var(--paper);
}

@media (min-width: 560px) {
  #app { padding-top: 40px; }
  .certificate-inner { padding: 36px 32px 28px; }
}
