/* ==========================================
   Al-Jazeera Arabic Typography
   ========================================== */
@font-face {
  font-family: 'Al-Jazeera';
  src: url('fonts/Al-Jazeera-Arabic-Regular.ttf') format('truetype');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

/* ==========================================
   Design System
   ========================================== */
:root {
  --navy: #002b5c;
  --navy-dark: #001a3a;
  --navy-light: #1a4a7a;
  --amber: #c9952b;
  --amber-light: #e8b84b;
  --amber-subtle: rgba(201, 149, 43, 0.12);
  --bg: #f9f9f9;
  --bg-card: #ffffff;
  --text-primary: #1a1a2e;
  --text-secondary: #5a5a7a;
  --text-muted: #8a8aaa;
  --border: #e2e4e9;
  --border-light: #eef0f3;
  --radius: 8px;
  --radius-lg: 12px;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.08);
  --font: 'Al-Jazeera', 'Segoe UI', 'Arial', sans-serif;
  --transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

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

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
  position: relative;
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='320' height='320' viewBox='0 0 320 320'%3E%3Cg fill='%23002b5c' opacity='0.06'%3E%3Cpath d='M60 200 L60 100 L140 100 L140 200 Z M60 100 L100 125 L140 100'/%3E%3Crect x='160' y='90' width='80' height='110' rx='4'/%3E%3Cpath d='M240 170 L280 155 L320 170 L280 185 Z M280 155 L280 120'/%3E%3Ccircle cx='75' cy='250' r='25'/%3E%3Cpath d='M75 225 L75 275 M50 250 L100 250'/%3E%3C/g%3E%3Cg fill='%23c9952b' opacity='0.04'%3E%3Crect x='30' y='30' width='60' height='40' rx='3'/%3E%3Crect x='33' y='33' width='54' height='8' rx='2'/%3E%3C/g%3E%3C/svg%3E");
  background-size: 320px 320px;
  background-repeat: repeat;
  pointer-events: none;
  z-index: 0;
}

body::after {
  content: '';
  position: fixed;
  inset: 0;
  background: linear-gradient(180deg, rgba(249,249,249,0.92) 0%, rgba(249,249,249,0.96) 50%, rgba(249,249,249,0.92) 100%);
  pointer-events: none;
  z-index: 1;
}

/* ==========================================
   Splash Screen
   ========================================== */
.splash {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--navy-dark) 0%, var(--navy) 50%, var(--navy-light) 100%);
  opacity: 1;
  transition: opacity 0.6s ease, visibility 0.6s ease;
  cursor: pointer;
}

.splash.fade-out {
  opacity: 0;
  visibility: hidden;
}

.splash-content {
  text-align: center;
  padding: 40px 24px;
  max-width: 480px;
}

.splash-ornament {
  font-size: 2.4rem;
  color: var(--amber);
  margin-bottom: 16px;
  line-height: 1;
  opacity: 0.7;
}

.splash-bismillah {
  font-size: 1.4rem;
  color: rgba(255,255,255,0.9);
  margin-bottom: 24px;
  line-height: 1.6;
}

.splash-divider {
  width: 60px;
  height: 2px;
  background: var(--amber);
  margin: 20px auto;
  opacity: 0.5;
  border-radius: 2px;
}

.splash-memorial {
  font-size: 1rem;
  color: rgba(255,255,255,0.6);
  margin-bottom: 8px;
  letter-spacing: 0.02em;
}

.splash-name {
  font-size: 1.6rem;
  color: #fff;
  font-weight: 700;
  margin-bottom: 12px;
  line-height: 1.3;
}

.splash-verse {
  font-size: 0.95rem;
  color: rgba(255,255,255,0.65);
  line-height: 1.7;
  max-width: 400px;
  margin: 0 auto;
}

.splash-sub {
  font-size: 0.85rem;
  color: rgba(255,255,255,0.5);
  margin-top: 4px;
}

.splash-credit {
  font-size: 0.8rem;
  color: rgba(255,255,255,0.4);
  margin-top: 8px;
}

.splash-hint {
  margin-top: 32px;
  font-size: 0.78rem;
  color: rgba(255,255,255,0.35);
  animation: pulse-hint 2s ease-in-out infinite;
}

@keyframes pulse-hint {
  0%, 100% { opacity: 0.35; }
  50% { opacity: 0.7; }
}

/* ==========================================
   Main Content
   ========================================== */
.main-content {
  opacity: 0;
  transform: translateY(16px);
  transition: opacity 0.6s ease, transform 0.6s ease;
  max-width: 720px;
  margin: 0 auto;
  padding: 0 16px 48px;
  position: relative;
  z-index: 2;
}

.main-content.visible {
  opacity: 1;
  transform: translateY(0);
}

.hidden {
  display: none !important;
}

/* ==========================================
   Header
   ========================================== */
header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 0 16px;
  gap: 16px;
  flex-wrap: wrap;
  border-bottom: 1px solid var(--border-light);
  margin-bottom: 24px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius);
  background: var(--amber-subtle);
  border: 1px solid rgba(201, 149, 43, 0.15);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--amber);
  flex-shrink: 0;
}

h1 {
  font-size: 1.25rem;
  font-weight: 700;
  line-height: 1.3;
  color: var(--navy);
}

.subtitle {
  display: block;
  font-size: 0.72rem;
  color: var(--text-muted);
  font-weight: 400;
  margin-top: 1px;
}

.stats-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 16px;
  border-radius: 100px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  font-size: 0.78rem;
}

.stat-num {
  font-weight: 700;
  color: var(--navy);
}

.stat-label {
  color: var(--text-muted);
}

.stat-sep {
  color: var(--border);
  margin: 0 2px;
}

/* ==========================================
   Search
   ========================================== */
.search-section {
  margin-bottom: 24px;
}

.search-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  max-width: 520px;
  margin: 0 auto;
}

.search-icon {
  position: absolute;
  right: 16px;
  color: var(--text-muted);
  pointer-events: none;
  z-index: 2;
}

.search-input {
  width: 100%;
  padding: 14px 48px 14px 48px;
  font-size: 0.95rem;
  font-family: var(--font);
  background: var(--bg-card);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-lg);
  color: var(--text-primary);
  outline: none;
  transition: var(--transition);
  box-shadow: var(--shadow-sm);
}

.search-input::placeholder {
  color: var(--text-muted);
  font-size: 0.9rem;
}

.search-input:focus {
  border-color: var(--amber);
  box-shadow: 0 0 0 3px var(--amber-subtle), var(--shadow-md);
}

.clear-btn {
  position: absolute;
  left: 8px;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 6px;
  border-radius: 6px;
  display: none;
  transition: var(--transition);
  z-index: 2;
}

.clear-btn:hover {
  color: var(--text-primary);
  background: var(--border-light);
}

.clear-btn.visible {
  display: flex;
  align-items: center;
  justify-content: center;
}

.search-stats {
  text-align: center;
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 8px;
  min-height: 20px;
}

/* ==========================================
   Results
   ========================================== */
.results-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  max-width: 520px;
  margin: 0 auto;
  contain: layout style;
  will-change: contents;
}

.scroll-sentinel {
  height: 4px;
  width: 100%;
  pointer-events: none;
}

/* ==========================================
   Student Card
   ========================================== */
.student-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  transition: var(--transition);
  box-shadow: var(--shadow-sm);
  will-change: transform;
  contain: layout style;
  position: relative;
  overflow: hidden;
}

.sc-badge {
  position: absolute;
  top: 0;
  left: 0;
  background: var(--navy);
  color: #fff;
  font-size: 0.62rem;
  font-weight: 600;
  padding: 3px 10px 3px 12px;
  border-radius: 0 0 8px 0;
  line-height: 1.4;
  z-index: 1;
}

.student-card:hover {
  border-color: #d0d4dd;
  box-shadow: var(--shadow-md);
}

.sc-top {
  display: flex;
  align-items: center;
  gap: 12px;
}

.sc-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--navy);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}

.sc-info {
  flex: 1;
  min-width: 0;
}

.sc-name {
  font-size: 0.92rem;
  font-weight: 600;
  line-height: 1.3;
  margin-bottom: 1px;
  color: var(--text-primary);
}

.sc-meta {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.sc-exam {
  font-family: 'Courier New', monospace;
  direction: ltr;
  color: var(--text-muted);
  font-size: 0.7rem;
}

.sc-sep {
  color: var(--border);
  margin: 0 2px;
}

.sc-center-label {
  color: var(--text-secondary);
}

.sc-center-label strong {
  color: var(--navy);
  font-weight: 600;
}

.sc-address {
  margin: 10px 0 0;
  padding: 8px 12px;
  background: #f5f6f8;
  border-radius: 6px;
  font-size: 0.75rem;
  color: var(--text-secondary);
  line-height: 1.5;
  border: 1px solid var(--border-light);
}

.sc-actions {
  margin-top: 12px;
}

mark {
  background: #fbbf24;
  border-radius: 2px;
  padding: 0 2px;
  color: inherit;
}

.map-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: 0.85rem;
  font-weight: 600;
  font-family: var(--font);
  cursor: pointer;
  border: none;
  transition: var(--transition);
  text-decoration: none;
  background: var(--navy);
  color: #fff;
  box-shadow: 0 2px 8px rgba(0, 43, 92, 0.2);
}

.map-btn:hover {
  background: var(--navy-light);
  box-shadow: 0 4px 14px rgba(0, 43, 92, 0.3);
  transform: translateY(-1px);
}

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

.map-btn.fallback {
  background: var(--amber);
  box-shadow: 0 2px 8px rgba(201, 149, 43, 0.25);
}

.map-btn.fallback:hover {
  background: var(--amber-light);
  box-shadow: 0 4px 14px rgba(201, 149, 43, 0.35);
}

.map-btn.disabled {
  background: #eef0f3;
  color: var(--text-muted);
  box-shadow: none;
  cursor: default;
  pointer-events: none;
}

/* ==========================================
   Loader
   ========================================== */
.loader-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  gap: 16px;
}

.loader-container p {
  color: var(--text-muted);
  font-size: 0.85rem;
}

.loader-spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--navy);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

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

/* ==========================================
   No Results
   ========================================== */
.no-results {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 60px 20px;
}

.no-results-icon {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: #f5f6f8;
  border: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  margin-bottom: 16px;
}

.no-results h3 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 8px;
}

.no-results p {
  font-size: 0.82rem;
  color: var(--text-muted);
  max-width: 300px;
  line-height: 1.6;
}

/* ==========================================
   Footer
   ========================================== */
footer {
  text-align: center;
  padding: 32px 0 16px;
  font-size: 0.75rem;
  color: var(--text-muted);
  border-top: 1px solid var(--border-light);
  margin-top: 24px;
}

/* ==========================================
   Animations
   ========================================== */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.student-card {
  animation: fadeInUp 0.35s ease forwards;
}

.student-card:nth-child(1) { animation-delay: 0.02s; }
.student-card:nth-child(2) { animation-delay: 0.04s; }
.student-card:nth-child(3) { animation-delay: 0.06s; }
.student-card:nth-child(4) { animation-delay: 0.08s; }
.student-card:nth-child(5) { animation-delay: 0.10s; }
.student-card:nth-child(6) { animation-delay: 0.12s; }
.student-card:nth-child(7) { animation-delay: 0.14s; }
.student-card:nth-child(8) { animation-delay: 0.16s; }
.student-card:nth-child(9) { animation-delay: 0.18s; }
.student-card:nth-child(10) { animation-delay: 0.20s; }

/* ==========================================
   Responsive
   ========================================== */
@media (max-width: 520px) {
  header {
    padding: 16px 0 12px;
    margin-bottom: 20px;
  }
  .logo-icon {
    width: 36px;
    height: 36px;
  }
  h1 {
    font-size: 1.1rem;
  }
  .search-input {
    padding: 12px 42px 12px 42px;
    font-size: 0.9rem;
  }
  .student-card {
    padding: 14px;
  }
  .sc-avatar {
    width: 32px;
    height: 32px;
    font-size: 0.78rem;
  }
  .sc-name {
    font-size: 0.88rem;
  }
  .sc-address {
    font-size: 0.72rem;
  }
  .map-btn {
    padding: 11px 14px;
    font-size: 0.82rem;
  }
  .splash-content {
    padding: 24px 16px;
  }
  .splash-name {
    font-size: 1.3rem;
  }
  .splash-bismillah {
    font-size: 1.15rem;
  }
}