/* Basic layout */

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #f3f4f6;
  color: #111827;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.container {
  max-width: 1100px;
  margin-inline: auto;
  padding-inline: 1rem;
  flex: 1;
  position: relative;
  margin-bottom: 2rem;
}

html[dir="rtl"] body {
  direction: rtl;
}

/* Hero */

.hero {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1.5rem;
  margin-bottom: 2rem;
}

.hero-text h1 {
  font-size: 2.1rem;
  margin: 0 0 0.5rem;
}

.hero-subtitle {
  margin: 0;
  color: #4b5563;
  max-width: 38rem;
}

/* Fields and buttons */

.field {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  font-size: 0.9rem;
  margin-bottom: 0.75rem;
}

.field-label {
  font-weight: 600;
  color: #4b5563;
}

select,
input[type="text"],
input[type="email"],
input[type="password"] {
  padding: 0.5rem 0.75rem;
  border-radius: 0.5rem;
  border: 1px solid #d1d5db;
  font-size: 0.95rem;
  min-width: 180px;
}

select:focus,
input[type="text"]:focus,
input[type="email"]:focus,
input[type="password"]:focus {
  outline: none;
  border-color: #2563eb;
  box-shadow:
    0 0 0 1px rgba(37, 99, 235, 0.3),
    0 0 0 4px rgba(37, 99, 235, 0.15);
}

.btn {
  border-radius: 0.5rem;
  padding: 0.6rem 1.2rem;
  font-size: 0.95rem;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: transform 0.1s ease, box-shadow 0.1s ease, background 0.1s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.btn.primary {
  background: #2563eb;
  color: white;
  box-shadow: 0 6px 14px rgba(37, 99, 235, 0.3);
}

.btn.primary:hover {
  background: #1d4ed8;
  transform: translateY(-1px);
}

.btn.secondary {
  background: #10b981;
  color: white;
  box-shadow: 0 6px 14px rgba(16, 185, 129, 0.3);
  text-decoration: none;
}

.btn.secondary:hover {
  background: #059669;
  transform: translateY(-1px);
}

.btn.link {
  background: transparent;
  color: #2563eb;
  box-shadow: none;
  padding-left: 0;
}

.btn.link:hover {
  text-decoration: underline;
}

.btn.danger {
  background: #dc2626;
  color: #ffffff;
}

.btn.small {
  padding: 0.35rem 0.7rem;
  font-size: 0.8rem;
}

.btn.full-width {
  width: 100%;
}

.btn:disabled,
.btn[disabled] {
  background: #d1d5db;
  color: #9ca3af;
  cursor: not-allowed;
  box-shadow: none;
  transform: none;
}

.btn:disabled:hover,
.btn[disabled]:hover {
  background: #d1d5db;
  transform: none;
}

.btn.secondary:disabled,
.btn.secondary[disabled] {
  background: #d1fae5;
  color: #6ee7b7;
}

.btn.primary:disabled,
.btn.primary[disabled] {
  background: #bfdbfe;
  color: #93c5fd;
}

#last-test-btn {
  font-size: 1.1rem;
  padding: 0.75rem 1.5rem;
}

/* Leaderboards */

.leaderboards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1.5rem;
  margin-bottom: 2.5rem;
}

.leaderboard-card {
  background: white;
  border-radius: 1rem;
  padding: 1.25rem 1.5rem;
  box-shadow: 0 12px 24px rgba(15, 23, 42, 0.08);
}

.leaderboard-card h2 {
  margin: 0 0 0.75rem;
  font-size: 1.05rem;
}

@media (min-width: 1200px) {
  .leaderboards {
    margin-top: 100px;
    width: 1000px;
  }

  .leaderboard-card.featured {
    position: relative;
    z-index:38;
    transform: translateY(-1rem) scale(1.25);
    box-shadow: 0 20px 40px rgba(15, 23, 42, 0.35);
  }

  .leaderboard-card.featured h2 {
    font-size: 1.25rem;
  }

  .leaderboard-card.featured .leaderboard-list {
    font-size: 1.1rem;
  }

  .religap {
    display: none;
    visibility: hidden;
  }
}

@media (min-width: 935px) and (max-width: 1199px) {
  .leaderboards {
    margin-top: 100px;
    width: 900px;
  }

  .leaderboard-card.featured {
    position: relative;
    z-index:38;
    transform: translateY(-1rem) scale(1.25);
    box-shadow: 0 20px 40px rgba(15, 23, 42, 0.35);
  }

  .leaderboard-card.featured h2 {
    font-size: 1.25rem;
  }

  .leaderboard-card.featured .leaderboard-list {
    font-size: 1.1rem;
  }

  .religap {
    display: none;
    visibility: hidden;
  }
}

@media (min-width: 779px) and (max-width: 934px) {
  .container {
    max-width: 779px;
  }

  .btn {
    margin-top: 20px;
  }

  .header-lang-select {
    margin-top: 20px;
  }

  .leaderboards {
    margin-top: 100px;
    max-width: 779px;
    grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  }

  .leaderboard-card {
    max-width: 280px;
    padding: 1.25rem 10px;
  }

  .leaderboard-card.featured {
    position: relative;
    z-index:38;
    transform: translateY(-1rem) scale(1.25);
    box-shadow: 0 20px 40px rgba(15, 23, 42, 0.35);
    max-width: 300px;
  }

  .leaderboard-card.featured h2 {
    font-size: 1rem;
  }

  .leaderboard-card.featured .leaderboard-list {
    font-size: 0.8rem;
  }

  .religap {
    display: none;
    visibility: hidden;
  }
}

@media (min-width: 580px) and (max-width: 779px) {
  .container {
    max-width: 779px;
  }

  .btn {
    margin-top: 20px;
  }

  .header-lang-select {
    margin-top: 20px;
  }

  .header-test-btn {
    display: inline-flex !important;
    visibility: visible !important;
  }

  .header-support-btn {
    display: none;
    visibility: hidden;
  }

  .leaderboards {
    margin-top: 20px;
    max-width: 500px;
    margin-left: auto;
    margin-right: auto;
    grid-template-columns: repeat(auto-fit, minmax(330px, 1fr));
  }

  .leaderboard-card.featured {
    position: relative;
    z-index:38;
    transform: scale(1.10);
    box-shadow: 0 20px 40px rgba(15, 23, 42, 0.35);
  }

  .leaderboard-card.featured h2 {
    font-size: 1.15rem;
  }

  .leaderboard-card.featured .leaderboard-list {
    font-size: 1.05rem;
  }

  .religap {
    display: inline-flex !important;
    visibility: visible !important;
    margin-bottom: 7rem;
  }

  .header-lang-select {
    max-width: 160px;
    min-width: 80px;
  }
}

@media (max-width: 579px) {
  .container {
    max-width: 574px;
  }

  .btn {
    margin-top: 20px;
  }

  .header-lang-select {
    margin-top: 20px;
  }

  .header-test-btn {
    display: inline-flex !important;
    visibility: visible !important;
  }

  .header-support-btn {
    display: none;
    visibility: hidden;
  }

  .leaderboards {
    margin-top: 20px;
  }

  .leaderboard-card.featured {
    position: relative;
    z-index:38;
    box-shadow: 0 20px 40px rgba(15, 23, 42, 0.35);
  }

  .leaderboard-card.featured h2 {
    font-size: 1.15rem;
  }

  .leaderboard-card.featured .leaderboard-list {
    font-size: 1.05rem;
  }

  .religap {
    display: inline-flex !important;
    visibility: visible !important;
    margin-bottom: 7rem;
  }

  .header-lang-select {
    max-width: 120px;
    min-width: 50px;
  }
}

.leaderboard-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.leaderboard-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.4rem 0;
  font-size: 0.9rem;
}

.leaderboard-left {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.leaderboard-rank {
  width: 1.5rem;
  text-align: center;
  font-weight: 700;
}

.rank-gold { color: #f59e0b; }
.rank-silver { color: #9ca3af; }
.rank-bronze { color: #b45309; }

.leaderboard-icon {
  width: 1.75rem;
  height: 1.75rem;
  border-radius: 999px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  color: white;
}

.leaderboard-name {
  font-weight: 500;
  color: #111827;
}

.leaderboard-value {
  font-weight: 700;
  color: #111827;
  white-space: nowrap;
}

/* Religion grid */

.religion-section h2 {
  margin: 0 0 0.25rem;
}

.section-subtitle {
  margin: 0 0 1rem;
  color: #6b7280;
  font-size: 0.9rem;
}

.religion-grid {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(1, minmax(0, 1fr));
}

@media (min-width: 600px) {
  .religion-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (min-width: 900px) {
  .religion-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (min-width: 1200px) {
  .religion-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

.religion-card {
  background: white;
  border-radius: 1rem;
  box-shadow: 0 16px 30px rgba(15, 23, 42, 0.08);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.religion-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 20px 40px rgba(15, 23, 42, 0.15);
}

.religion-bar {
  height: 4px;
}

/* Colors */
.bg-sky { background: linear-gradient(90deg, #0ea5e9, #2563eb); }
.bg-emerald { background: linear-gradient(90deg, #10b981, #059669); }
.bg-amber { background: linear-gradient(90deg, #f59e0b, #d97706); }
.bg-rose { background: linear-gradient(90deg, #f97373, #be123c); }
.bg-indigo { background: linear-gradient(90deg, #6366f1, #4f46e5); }
.bg-violet { background: linear-gradient(90deg, #8b5cf6, #7c3aed); }
.bg-teal { background: linear-gradient(90deg, #14b8a6, #0f766e); }
.bg-slate { background: linear-gradient(90deg, #6b7280, #374151); }
.bg-amber-solid { background: #f59e0b; }

.religion-card-body {
  padding: 1.1rem 1.25rem 1.3rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.religion-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.religion-avatar {
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 999px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 1.35rem;
}

.religion-name {
  font-size: 1.05rem;
  font-weight: 700;
}

.religion-stats {
  display: flex;
  justify-content: space-between;
  font-size: 0.85rem;
  color: #6b7280;
}

.religion-stat-block {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex: 1;
}

.religion-stat-value {
  font-weight: 700;
  font-size: 1rem;
  color: #111827;
}

.religion-card-footer {
  margin-top: 0.75rem;
}

.religion-card-footer .btn {
  width: 100%;
}

/* Quiz Screen */

.quiz-screen {
  max-width: 640px;
  margin: 0 auto;
  padding: 1rem 1rem 2rem;
  position: relative;
  z-index: 101;
}

.quiz-screen > h2 {
  background: #ffffff;
  padding: 0.75rem 1rem;
  border-radius: 0.75rem;
  margin-bottom: 1rem;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.quiz-card {
  background: #ffffff;
  border-radius: 1rem;
  padding: 1.25rem 1.25rem 1.5rem;
  box-shadow: 0 10px 25px rgba(15, 23, 42, 0.12);
  border: 1px solid rgba(148, 163, 184, 0.4);
}

.quiz-header {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.quiz-counter {
  font-size: 0.9rem;
  font-weight: 600;
  color: #64748b;
}

.quiz-progress-bar {
  width: 100%;
  height: 6px;
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.2);
  overflow: hidden;
}

.quiz-progress-fill {
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, #0ea5e9, #22c55e);
  border-radius: 999px;
  transition: width 0.25s ease-out;
}

.quiz-question-text {
  font-size: 1.05rem;
  font-weight: 600;
  color: #0f172a;
  margin-bottom: 1rem;
  line-height: 1.5;
}

.quiz-options {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.quiz-option {
  display: block;
  cursor: pointer;
}

.quiz-option-input {
  display: none;
}

.quiz-option-text {
  display: block;
  padding: 0.75rem 0.9rem;
  border-radius: 0.75rem;
  border: 1px solid rgba(148, 163, 184, 0.7);
  background: #f9fafb;
  font-size: 0.95rem;
  color: #0f172a;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.08s ease;
}

.quiz-option:hover .quiz-option-text {
  border-color: #0ea5e9;
  background: #eef2ff;
}

.quiz-option-input:checked + .quiz-option-text {
  border-color: #0ea5e9;
  background: #dbeafe;
  box-shadow: 0 0 0 1px rgba(37, 99, 235, 0.15);
  transform: translateY(-1px);
}

.quiz-actions {
  margin-top: 1rem;
  display: flex;
  justify-content: flex-end;
}

/* Result Screen */

.result-screen {
  display: none;
  padding: 1.5rem 1rem 2.5rem;
  background: transparent;
  position: relative;
  z-index: 101;
}

.result-card {
  max-width: 960px;
  margin: 0 auto;
  background: #ffffff;
  border-radius: 1.25rem;
  padding: 1.5rem 1.75rem 2rem;
  box-shadow: 0 12px 30px rgba(15, 23, 42, 0.12);
  border: none;
}

.result-card > h2 {
  margin-top: 0;
  margin-bottom: 0.75rem;
}

.result-score {
  font-weight: 700;
  font-size: 1.1rem;
  margin-bottom: 0.75rem;
}

.result-feedback {
  font-size: 0.95rem;
  line-height: 1.6;
  color: #4b5563;
  margin-bottom: 1.25rem;
}

/* Two-column grid for email + share */
.result-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.result-box {
  flex: 1 1 0;
  min-width: 260px;
  background: #f9fafb;
  border-radius: 1rem;
  padding: 1rem 1.1rem;
  border: 1px solid #e5e7eb;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 230px;
}

.result-box h3 {
  margin-top: 0;
  margin-bottom: 0.5rem;
}

.result-box > p {
  margin-top: 0;
  margin-bottom: auto;
  flex: 1;
}

.result-box .field {
  margin-bottom: 0.5rem;
}

.result-box .btn {
  width: 100%;
  margin: 0;
}

.result-box > p:last-of-type {
  padding-bottom: 1rem;
}

.result-section-title {
  font-size: 0.95rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
  color: #111827;
}

.share-buttons {
  margin-top: 0.75rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.36rem;
  justify-content: center;
}


.btn-icon {
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 0.5rem;
  border: 1px solid #d1d5db;
  background: #ffffff;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  transition: transform 0.1s ease, box-shadow 0.1s ease;
}

.btn-icon:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
  border-color: #2563eb;
}

.btn-icon:active {
  transform: translateY(0);
}

.result-footer {
  margin-top: 1.25rem;
  display: flex;
  justify-content: space-between;
  gap: 1rem;
}

/* Modals */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.65);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9998;
}

.quiz-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  z-index: 100;
  display: none;
  width: 100vw;
  height: 100vh;
}

.quiz-overlay.active {
  display: block;
}

/* Lighter overlay when quiz is active (for background readability) */
.quiz-overlay.quiz-bg-overlay {
  background: rgba(255, 255, 255, 0.70);
  z-index: 100;
}

.modal {
  background: white;
  border-radius: 1rem;
  padding: 1.5rem 1.75rem;
  max-width: 420px;
  width: 90%;
  box-shadow: 0 20px 50px rgba(15, 23, 42, 0.4);
  position: relative;
}

.modal-close-x {
  position: absolute;
  top: 1rem;
  right: 1rem;
  background: none;
  border: none;
  font-size: 2rem;
  line-height: 1;
  color: #6b7280;
  cursor: pointer;
  padding: 0;
  width: 2rem;
  height: 2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.2s;
}

.modal-close-x:hover {
  color: #111827;
}

.modal h2 { margin: 0 0 0.5rem; }
.modal-body { margin: 0; color: #4b5563; font-size: 0.95rem; }

/* Universal Modal Styling */
.universal-modal {
  text-align: left;
  padding-top: 2.5rem;
}

.universal-modal .modal-title {
  font-size: 1.1rem;
  font-weight: 600;
  margin: 0 0 0.75rem 0;
  color: #0f172a;
}

.universal-modal .modal-message {
  font-size: 0.95rem;
  color: #4b5563;
  margin: 0 0 1rem 0;
  line-height: 1.5;
}

.universal-modal .modal-icon {
  display: none;
}

.universal-modal .modal-actions {
  justify-content: center;
  margin-top: 1.25rem;
}

.universal-modal .btn.primary {
  min-width: 80px;
}

.modal-card {
  background: #ffffff;
  border-radius: 1rem;
  max-width: 420px;
  width: 90%;
  padding: 1.5rem 1.75rem;
  box-shadow: 0 18px 40px rgba(15, 23, 42, 0.45);
  border: 1px solid rgba(148, 163, 184, 0.5);
  position: relative;
}

.modal-actions {
  margin-top: 1rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: flex-end;
}

/* Loading Overlay */
#loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  color: #ffffff;
  font-family: inherit;
  animation: fadeInOverlay 0.2s ease-out;
}

#loading-overlay.visible {
  display: flex;
}

.loading-box {
  background: rgba(15, 23, 42, 0.9);
  padding: 1.5rem 2rem;
  border-radius: 1rem;
  border: 1px solid rgba(148, 163, 184, 0.6);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
}

.spinner {
  width: 40px;
  height: 40px;
  border-radius: 999px;
  border: 4px solid rgba(148, 163, 184, 0.5);
  border-top-color: #ffffff;
  animation: spin 0.8s linear infinite;
}

.loading-text {
  font-size: 1rem;
  font-weight: 600;
}

body.loading main {
  filter: blur(2px);
  pointer-events: none;
}

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes fadeInOverlay { from { opacity: 0; } to { opacity: 1; } }

/* Global Header */
.site-header {
  background: #111827;
  color: #f9fafb;
  padding: 0.8rem 1rem;
  box-shadow: 0 2px 6px rgba(0,0,0,0.15);
  position: sticky;
  top: 0;
  z-index: 39; /* RCX */
}

.header-inner {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
}

.header-title {
  text-decoration: none;
  color: #f9fafb;
  display: flex;
  flex-direction: column;
  line-height: 1.1;
}

.brand { font-size: 1.25rem; font-weight: 800; }
.tagline { font-size: 0.8rem; font-weight: 400; color: #cbd5e1; }

.header-right {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.header-lang-select {
  border-radius: 0.35rem;
  border: 1px solid #94a3b8;
  background: #f9fafb;
  color: #111827;
}

.header-test-btn {
  display: none;
  visibility: hidden;  
}

/* Footer */
.site-footer {
  margin-top: auto;
  background: #0f172a;
  color: #e2e8f0;
  padding: 1.5rem 1rem;
  text-align: center;
}

.footer-links a {
  color: #93c5fd;
  text-decoration: underline;
}

.footer-sep { padding: 0 0.3rem; }

/* Responsive tweaks */
@media (max-width: 640px) {
  .hero-text h1 { font-size: 1.6rem; }
  .result-grid { flex-direction: column; }
  .result-card { padding: 1.25rem 1rem; }
  .header-inner { flex-direction: column; align-items: flex-start; gap: 0.6rem; }
  .header-right { width: 100%; justify-content: flex-start; }
}

html[dir="rtl"] body { direction: rtl; }
html[dir="rtl"] .leaderboard-item { flex-direction: row-reverse; }
html[dir="rtl"] .leaderboard-left { flex-direction: row-reverse; }

/* Admin Kpi */
.kpi-row { display: flex; flex-wrap: wrap; gap: 1rem; }
.kpi-card {
  flex: 1 1 160px;
  background: #ffffff;
  border-radius: 0.75rem;
  padding: 0.8rem 1rem;
  box-shadow: 0 10px 25px rgba(15, 23, 42, 0.08);
  border: 1px solid rgba(148, 163, 184, 0.4);
}
.kpi-label { font-size: 0.8rem; color: #6b7280; }
.kpi-value { font-size: 1.4rem; font-weight: 700; }

.share-generator {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: flex-end;
}
.share-generator .field { min-width: 180px; }
#share-link-output { width: 100%; }

#admin-login-status {
  margin-top: 0.75rem;
  font-size: 0.85rem;
  text-align: left;
  color: #dc2626;
}

.quiz-actions {
  display: none;
}

.featured {
  display: flex;
  flex-direction: column;
}

.leaderboard-card .howGenerousIs {
  margin-top: auto;
  padding-top: 20px;;
  margin-bottom: 0;
  font-size: 0.8rem;
  font-weight: bolder;
  text-align: center;
}
