/* ============================================
   Village Genealogy — Pindwara, Rajasthan
   Mobile-first, high-contrast, elder-friendly
   ============================================ */

@import url('https://fonts.googleapis.com/css2?family=Noto+Sans+Devanagari:wght@400;500;600;700;800;900&display=swap');

/* ---------- Design Tokens ---------- */
:root {
  --bg-primary: #0f0a0a;
  --bg-card: rgba(45, 15, 15, 0.65);
  --bg-card-hover: rgba(60, 20, 20, 0.75);
  --bg-glass: rgba(255, 255, 255, 0.04);
  --bg-input: rgba(255, 255, 255, 0.07);

  --text-primary: #fef3e2;
  --text-secondary: #c9a96e;
  --text-muted: #8a7a5a;
  --text-accent: #ff9f43;

  --accent-saffron: #ff9f43;
  --accent-maroon: #8b1a1a;
  --accent-gold: #d4a843;
  --accent-deep: #c0392b;
  --accent-green: #27ae60;

  --border-subtle: rgba(212, 168, 67, 0.15);
  --border-glow: rgba(255, 159, 67, 0.3);

  --shadow-card: 0 8px 32px rgba(0, 0, 0, 0.45);
  --shadow-glow: 0 0 40px rgba(255, 159, 67, 0.08);

  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-xl: 28px;

  --font-family: 'Noto Sans Devanagari', 'Segoe UI', system-ui, sans-serif;
  --font-size-base: 18px;
  --font-size-sm: 15px;
  --font-size-lg: 22px;
  --font-size-xl: 28px;
  --font-size-hero: 36px;

  --transition-fast: 0.2s ease;
  --transition-med: 0.35s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ---------- Reset & Base ---------- */
*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  font-size: var(--font-size-base);
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

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

/* Subtle background pattern */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse 800px 600px at 20% 20%, rgba(139, 26, 26, 0.2) 0%, transparent 70%),
    radial-gradient(ellipse 600px 500px at 80% 80%, rgba(212, 168, 67, 0.08) 0%, transparent 70%),
    radial-gradient(ellipse 400px 400px at 50% 50%, rgba(255, 159, 67, 0.04) 0%, transparent 70%);
  pointer-events: none;
  z-index: 0;
}

/* ---------- App Container ---------- */
.app-container {
  position: relative;
  z-index: 1;
  max-width: 720px;
  margin: 0 auto;
  padding: 20px 16px 100px;
}

/* ---------- Header ---------- */
.app-header {
  text-align: center;
  padding: 32px 0 24px;
  position: relative;
}

.app-header__emblem {
  width: 64px;
  height: 64px;
  margin: 0 auto 16px;
  background: linear-gradient(135deg, var(--accent-saffron), var(--accent-maroon));
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 30px;
  box-shadow: 0 0 30px rgba(255, 159, 67, 0.25);
  animation: emblemPulse 3s ease-in-out infinite;
}

@keyframes emblemPulse {

  0%,
  100% {
    box-shadow: 0 0 30px rgba(255, 159, 67, 0.25);
  }

  50% {
    box-shadow: 0 0 50px rgba(255, 159, 67, 0.4);
  }
}

.app-header__title {
  font-size: var(--font-size-hero);
  font-weight: 800;
  background: linear-gradient(135deg, var(--accent-saffron), var(--accent-gold), var(--text-primary));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  line-height: 1.2;
  letter-spacing: -0.5px;
}

.app-header__subtitle {
  font-size: var(--font-size-sm);
  color: var(--text-muted);
  margin-top: 6px;
  font-weight: 400;
}

.app-header__divider {
  width: 60px;
  height: 3px;
  background: linear-gradient(90deg, transparent, var(--accent-saffron), transparent);
  margin: 16px auto 0;
  border-radius: 2px;
}

/* ---------- Search Section ---------- */
.search-section {
  margin-top: 24px;
}

.search-box {
  position: relative;
}

.search-box__input {
  width: 100%;
  padding: 18px 56px 18px 20px;
  font-size: var(--font-size-lg);
  font-family: var(--font-family);
  font-weight: 500;
  color: var(--text-primary);
  background: var(--bg-input);
  border: 1.5px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  outline: none;
  transition: all var(--transition-med);
  backdrop-filter: blur(10px);
}

.search-box__input::placeholder {
  color: var(--text-muted);
  font-weight: 400;
  font-size: var(--font-size-base);
}

.search-box__input:focus {
  border-color: var(--accent-saffron);
  box-shadow: 0 0 0 3px rgba(255, 159, 67, 0.12), var(--shadow-glow);
  background: rgba(255, 255, 255, 0.09);
}

.search-box__btn {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  width: 44px;
  height: 44px;
  border: none;
  background: linear-gradient(135deg, var(--accent-saffron), var(--accent-deep));
  color: #fff;
  border-radius: var(--radius-md);
  font-size: 20px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
}

.search-box__btn:hover {
  transform: translateY(-50%) scale(1.06);
  box-shadow: 0 4px 20px rgba(255, 159, 67, 0.3);
}

.search-box__btn:active {
  transform: translateY(-50%) scale(0.96);
}

/* ---------- Hint / Suggestion Box ---------- */
.hint-box {
  margin-top: 12px;
  min-height: 0;
  overflow: hidden;
  transition: all var(--transition-med);
}

.hint-box.hidden {
  opacity: 0;
  max-height: 0;
  margin-top: 0;
}

.hint-box__label {
  font-size: var(--font-size-sm);
  color: var(--text-muted);
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.hint-box__label::before {
  content: '💡';
  font-size: 14px;
}

.hint-box__buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.hint-btn {
  padding: 10px 16px;
  font-size: var(--font-size-sm);
  font-family: var(--font-family);
  font-weight: 500;
  color: var(--text-secondary);
  background: var(--bg-glass);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  cursor: pointer;
  transition: all var(--transition-fast);
  white-space: nowrap;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  animation: hintSlideIn 0.3s ease backwards;
}

.hint-btn:nth-child(1) {
  animation-delay: 0s;
}

.hint-btn:nth-child(2) {
  animation-delay: 0.06s;
}

.hint-btn:nth-child(3) {
  animation-delay: 0.12s;
}

.hint-btn:nth-child(4) {
  animation-delay: 0.18s;
}

.hint-btn:nth-child(5) {
  animation-delay: 0.24s;
}

.hint-btn:nth-child(6) {
  animation-delay: 0.30s;
}

.hint-btn:nth-child(7) {
  animation-delay: 0.36s;
}

.hint-btn:nth-child(8) {
  animation-delay: 0.42s;
}

@keyframes hintSlideIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.hint-btn:hover {
  color: var(--text-primary);
  background: rgba(255, 159, 67, 0.12);
  border-color: var(--accent-saffron);
}

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

.hint-btn__icon {
  font-size: 13px;
  margin-right: 2px;
}

/* ---------- Name Autocomplete ---------- */
.autocomplete-box {
  margin-top: 8px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  overflow: hidden;
  backdrop-filter: blur(12px);
  box-shadow: var(--shadow-card);
}

.autocomplete-box.hidden {
  display: none;
}

.autocomplete-item {
  padding: 12px 16px;
  font-size: var(--font-size-base);
  color: var(--text-primary);
  cursor: pointer;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  transition: background var(--transition-fast);
  display: flex;
  align-items: center;
  gap: 10px;
}

.autocomplete-item:last-child {
  border-bottom: none;
}

.autocomplete-item:hover,
.autocomplete-item.active {
  background: rgba(255, 159, 67, 0.1);
}

.autocomplete-item__icon {
  font-size: 14px;
  opacity: 0.5;
}

/* ---------- s/o Label ---------- */
.so-label {
  color: var(--text-muted);
  font-weight: 400;
  font-size: 0.8em;
  margin-left: 4px;
}

/* ---------- "My Identity" Selector ---------- */
.identity-section {
  margin-top: 20px;
  padding: 14px 16px;
  background: var(--bg-glass);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.identity-section__label {
  font-size: var(--font-size-sm);
  color: var(--text-muted);
  white-space: nowrap;
}

.identity-section__name {
  font-size: var(--font-size-sm);
  font-weight: 600;
  color: var(--accent-saffron);
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.identity-section__btn {
  padding: 8px 14px;
  font-size: var(--font-size-sm);
  font-family: var(--font-family);
  font-weight: 500;
  color: var(--text-secondary);
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.identity-section__btn:hover {
  background: rgba(255, 159, 67, 0.12);
  border-color: var(--accent-saffron);
  color: var(--text-primary);
}

/* ---------- Results Section ---------- */
.results-section {
  margin-top: 28px;
}

.result-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 24px 20px;
  margin-bottom: 16px;
  backdrop-filter: blur(12px);
  box-shadow: var(--shadow-card);
  animation: cardFadeIn 0.4s ease;
  transition: border-color var(--transition-fast);
}

.result-card:hover {
  border-color: var(--border-glow);
}

@keyframes cardFadeIn {
  from {
    opacity: 0;
    transform: translateY(16px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.result-card__header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}

.result-card__icon {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}

.result-card__icon--father {
  background: linear-gradient(135deg, rgba(139, 26, 26, 0.5), rgba(212, 168, 67, 0.3));
}

.result-card__icon--children {
  background: linear-gradient(135deg, rgba(39, 174, 96, 0.4), rgba(46, 204, 113, 0.2));
}

.result-card__icon--relation {
  background: linear-gradient(135deg, rgba(52, 152, 219, 0.4), rgba(155, 89, 182, 0.3));
}

.result-card__icon--info {
  background: linear-gradient(135deg, rgba(255, 159, 67, 0.4), rgba(255, 159, 67, 0.2));
}

.result-card__title {
  font-size: var(--font-size-lg);
  font-weight: 700;
  color: var(--text-primary);
}

.result-card__subtitle {
  font-size: var(--font-size-sm);
  color: var(--text-muted);
}

.result-card__body {
  font-size: var(--font-size-base);
  color: var(--text-secondary);
  line-height: 1.7;
}

.result-card__name {
  font-weight: 700;
  color: var(--accent-saffron);
}

.result-card__note {
  margin-top: 12px;
  font-size: var(--font-size-sm);
  color: var(--text-muted);
  padding: 10px 14px;
  background: var(--bg-glass);
  border-radius: var(--radius-sm);
  border-left: 3px solid var(--accent-gold);
}

/* ---------- Info Grid ---------- */
.info-grid {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 6px;
}

.info-row {
  display: flex;
  gap: 8px;
  align-items: baseline;
  padding: 6px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.03);
}

.info-row:last-child {
  border-bottom: none;
}

.info-label {
  font-weight: 600;
  color: var(--text-muted);
  white-space: nowrap;
  font-size: var(--font-size-sm);
}

.info-value {
  color: var(--text-secondary);
  font-size: var(--font-size-sm);
}

/* ---------- Relation Summary ---------- */
.relation-summary {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 14px 16px;
  background: linear-gradient(135deg, rgba(255, 159, 67, 0.08), rgba(212, 168, 67, 0.05));
  border: 1px solid rgba(255, 159, 67, 0.15);
  border-radius: var(--radius-md);
  margin-bottom: 14px;
}

.relation-summary__emoji {
  font-size: 24px;
  flex-shrink: 0;
  line-height: 1;
  margin-top: 2px;
}

.relation-summary__text {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--accent-saffron);
  line-height: 1.5;
}

.relation-meta {
  display: flex;
  gap: 16px;
  margin-bottom: 14px;
  font-size: var(--font-size-sm);
  color: var(--text-muted);
}

.relation-meta__item {
  display: flex;
  align-items: center;
  gap: 4px;
}

/* ---------- Path Timeline (new) ---------- */
.path-timeline {
  margin-top: 4px;
  position: relative;
}

.path-tl-node {
  display: flex;
  gap: 14px;
  animation: pathTlIn 0.35s ease backwards;
}

.path-tl-node:nth-child(1) {
  animation-delay: 0s;
}

.path-tl-node:nth-child(2) {
  animation-delay: 0.12s;
}

.path-tl-node:nth-child(3) {
  animation-delay: 0.24s;
}

.path-tl-node:nth-child(4) {
  animation-delay: 0.36s;
}

.path-tl-node:nth-child(5) {
  animation-delay: 0.48s;
}

.path-tl-node:nth-child(6) {
  animation-delay: 0.60s;
}

.path-tl-node:nth-child(7) {
  animation-delay: 0.72s;
}

.path-tl-node:nth-child(8) {
  animation-delay: 0.84s;
}

.path-tl-node:nth-child(9) {
  animation-delay: 0.96s;
}

.path-tl-node:nth-child(10) {
  animation-delay: 1.08s;
}

@keyframes pathTlIn {
  from {
    opacity: 0;
    transform: translateX(-10px);
  }

  to {
    opacity: 1;
    transform: translateX(0);
  }
}

.path-tl-marker {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 20px;
  flex-shrink: 0;
}

.path-tl-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent-gold);
  border: 2px solid rgba(255, 255, 255, 0.15);
  flex-shrink: 0;
  z-index: 2;
}

.path-tl-node--start .path-tl-dot {
  background: var(--accent-green);
  border-color: rgba(39, 174, 96, 0.4);
  box-shadow: 0 0 10px rgba(39, 174, 96, 0.35);
  width: 16px;
  height: 16px;
}

.path-tl-node--end .path-tl-dot {
  background: var(--accent-deep);
  border-color: rgba(192, 57, 43, 0.4);
  box-shadow: 0 0 10px rgba(192, 57, 43, 0.35);
  width: 16px;
  height: 16px;
}

.path-tl-node--pivot .path-tl-dot {
  background: var(--accent-saffron);
  border-color: rgba(255, 159, 67, 0.5);
  box-shadow: 0 0 12px rgba(255, 159, 67, 0.4);
  width: 18px;
  height: 18px;
}

.path-tl-line {
  flex: 1;
  width: 2px;
  background: linear-gradient(180deg, var(--accent-gold), rgba(212, 168, 67, 0.25));
  min-height: 8px;
}

.path-tl-line-only {
  display: block;
  width: 2px;
  height: 100%;
  min-height: 14px;
  background: rgba(212, 168, 67, 0.2);
  margin: 0 auto;
}

.path-tl-content {
  padding: 6px 12px 10px;
  flex: 1;
  min-width: 0;
}

.path-tl-badge {
  display: inline-block;
  font-size: 11px;
  color: var(--text-muted);
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 20px;
  padding: 2px 8px;
  margin-bottom: 3px;
}

.path-tl-node--start .path-tl-badge {
  color: var(--accent-green);
  border-color: rgba(39, 174, 96, 0.25);
  background: rgba(39, 174, 96, 0.08);
}

.path-tl-node--end .path-tl-badge {
  color: var(--accent-deep);
  border-color: rgba(192, 57, 43, 0.25);
  background: rgba(192, 57, 43, 0.08);
}

.path-tl-node--pivot .path-tl-badge {
  color: var(--accent-saffron);
  border-color: rgba(255, 159, 67, 0.25);
  background: rgba(255, 159, 67, 0.08);
}

.path-tl-name {
  font-weight: 600;
  color: var(--text-primary);
  font-size: var(--font-size-sm);
  display: block;
  line-height: 1.4;
}

.path-tl-edge {
  display: flex;
  gap: 14px;
}

.path-tl-edge-label {
  padding: 0 12px;
  font-size: 12px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 4px;
}

.path-tl-arrow {
  font-weight: 700;
  color: var(--accent-gold);
  font-size: 14px;
}

/* ---------- Children List ---------- */
.children-list {
  list-style: none;
  margin-top: 12px;
}

.children-list__item {
  padding: 10px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  animation: childItemIn 0.3s ease backwards;
}

.children-list__item:last-child {
  border-bottom: none;
}

.children-list__item:nth-child(1) {
  animation-delay: 0s;
}

.children-list__item:nth-child(2) {
  animation-delay: 0.06s;
}

.children-list__item:nth-child(3) {
  animation-delay: 0.12s;
}

.children-list__item:nth-child(4) {
  animation-delay: 0.18s;
}

.children-list__item:nth-child(5) {
  animation-delay: 0.24s;
}

.children-list__item:nth-child(6) {
  animation-delay: 0.30s;
}

@keyframes childItemIn {
  from {
    opacity: 0;
    transform: translateX(-8px);
  }

  to {
    opacity: 1;
    transform: translateX(0);
  }
}

.children-list__bullet {
  color: var(--accent-gold);
  font-size: 13px;
  font-weight: 700;
  min-width: 22px;
}

.children-list__name {
  font-weight: 600;
  color: var(--text-primary);
}

/* ---------- No-result / Error ---------- */
.no-result {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-muted);
}

.no-result__emoji {
  font-size: 40px;
  margin-bottom: 12px;
  display: block;
}

.no-result__text {
  font-size: var(--font-size-base);
}

/* ---------- Stats Bar ---------- */
.stats-bar {
  margin-top: 16px;
  padding: 12px 16px;
  background: var(--bg-glass);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  display: flex;
  justify-content: center;
  gap: 24px;
  font-size: var(--font-size-sm);
  color: var(--text-muted);
}

.stats-bar__item {
  display: flex;
  align-items: center;
  gap: 6px;
}

.stats-bar__value {
  font-weight: 700;
  color: var(--accent-saffron);
}

/* ---------- Footer ---------- */
.app-footer {
  text-align: center;
  padding: 32px 0;
  font-size: 13px;
  color: var(--text-muted);
  opacity: 0.6;
}

/* ---------- Loading Spinner ---------- */
.loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 32px;
}

.loading__spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--border-subtle);
  border-top-color: var(--accent-saffron);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

.loading__text {
  font-size: var(--font-size-sm);
  color: var(--text-muted);
}

/* ---------- Responsive ---------- */
@media (max-width: 480px) {
  :root {
    --font-size-hero: 28px;
    --font-size-xl: 24px;
    --font-size-lg: 20px;
    --font-size-base: 17px;
  }

  .app-container {
    padding: 12px 12px 80px;
  }

  .search-box__input {
    padding: 16px 50px 16px 16px;
    font-size: var(--font-size-base);
  }

  .hint-btn {
    font-size: 14px;
    padding: 8px 12px;
  }

  .result-card {
    padding: 18px 16px;
  }

  .stats-bar {
    gap: 16px;
    flex-wrap: wrap;
    justify-content: center;
  }
}

@media (min-width: 768px) {
  .app-container {
    padding: 40px 24px 100px;
  }

  .app-header {
    padding: 48px 0 32px;
  }

  .app-header__emblem {
    width: 80px;
    height: 80px;
    font-size: 38px;
  }

  :root {
    --font-size-hero: 44px;
  }
}

/* ---------- Accessibility ---------- */
@media (prefers-reduced-motion: reduce) {

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

/* Focus-visible for keyboard nav */
:focus-visible {
  outline: 2px solid var(--accent-saffron);
  outline-offset: 2px;
}

/* Touch targets */
button,
.hint-btn,
.autocomplete-item,
.identity-section__btn {
  min-height: 44px;
}