/* ==========================================================
   Baby Name Base — Stylesheet
   ========================================================== */

:root {
  --bg: #fafafa;
  --surface: #ffffff;
  --surface-2: #f5f3ff;
  --border: #e5e7eb;
  --text: #1a1a2e;
  --text-secondary: #6b7280;
  --text-muted: #9ca3af;
  --primary: #8b5cf6;
  --primary-dark: #7c3aed;
  --primary-light: #ede9fe;
  --accent: #f59e0b;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.04);
  --shadow: 0 2px 4px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
  --transition: 0.2s ease;
}

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

html { scroll-behavior: smooth; }

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

.container { max-width: 1100px; margin: 0 auto; padding: 0 20px; }

a { color: inherit; text-decoration: none; transition: color var(--transition); }
a:hover { color: var(--primary); }

h1, h2, h3, h4 { font-family: 'Playfair Display', Georgia, serif; line-height: 1.2; }

/* ── Header ── */
.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}
.site-header .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 16px;
  padding-bottom: 16px;
}
.logo { display: flex; align-items: center; gap: 8px; font-weight: 700; }
.logo-mark { color: var(--primary); font-size: 1.4rem; }
.logo-text { font-family: 'Playfair Display', serif; font-size: 1.3rem; font-weight: 700; }
.main-nav { display: flex; gap: 28px; }
.main-nav a { color: var(--text-secondary); font-weight: 500; font-size: 0.95rem; }
.main-nav a:hover { color: var(--text); }

/* ── Hero ── */
.hero {
  background: linear-gradient(180deg, var(--surface-2) 0%, var(--bg) 100%);
  padding: 72px 0 56px;
  text-align: center;
}
.hero h1 {
  font-size: 3rem;
  font-weight: 800;
  margin-bottom: 16px;
  letter-spacing: -1px;
}
.hero-subtitle {
  font-size: 1.15rem;
  color: var(--text-secondary);
  max-width: 640px;
  margin: 0 auto 32px;
}

/* Search Box */
.search-box {
  position: relative;
  max-width: 560px;
  margin: 0 auto;
  display: flex;
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  transition: border-color var(--transition);
}
.search-box:focus-within { border-color: var(--primary); box-shadow: 0 0 0 4px rgba(139,92,246,0.1); }
.search-box input {
  flex: 1;
  padding: 16px 20px;
  border: none;
  font-size: 1rem;
  font-family: inherit;
  background: transparent;
  outline: none;
}
.search-box button {
  padding: 16px 28px;
  border: none;
  background: var(--primary);
  color: white;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: background var(--transition);
}
.search-box button:hover { background: var(--primary-dark); }

.search-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md);
  max-height: 400px;
  overflow-y: auto;
  display: none;
  z-index: 50;
}
.search-dropdown.show { display: block; }
.search-result-item {
  padding: 12px 18px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  text-align: left;
  transition: background var(--transition);
}
.search-result-item:last-child { border-bottom: none; }
.search-result-item:hover { background: var(--primary-light); }
.search-result-name { font-weight: 700; font-size: 1rem; }
.search-result-info { font-size: 0.85rem; color: var(--text-secondary); margin-top: 2px; }

.hero-stats {
  display: flex;
  gap: 40px;
  justify-content: center;
  margin-top: 32px;
  color: var(--text-secondary);
  font-size: 0.95rem;
}
.hero-stats strong { color: var(--text); font-size: 1.4rem; font-weight: 700; }
.hero-stats span { display: flex; flex-direction: column; align-items: center; gap: 4px; }

/* ── Sections ── */
.section { padding: 64px 0; }
.section-alt { background: var(--surface); }
.section-title {
  font-size: 2rem;
  font-weight: 700;
  margin-bottom: 32px;
  text-align: center;
}

/* ── Culture Grid ── */
.culture-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 16px;
}
.culture-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px 16px;
  text-align: center;
  transition: all var(--transition);
  box-shadow: var(--shadow-sm);
}
.section-alt .culture-card { background: var(--bg); }
.culture-card:hover {
  border-color: var(--primary);
  transform: translateY(-4px);
  box-shadow: var(--shadow-md);
}
.culture-emoji { font-size: 2.4rem; display: block; margin-bottom: 8px; }
.culture-name { display: block; font-weight: 700; color: var(--text); margin-bottom: 4px; }
.culture-count { display: block; font-size: 0.85rem; color: var(--text-muted); }

/* ── Letter Grid ── */
.letter-grid {
  display: grid;
  grid-template-columns: repeat(13, 1fr);
  gap: 8px;
  max-width: 800px;
  margin: 0 auto;
}
.letter-btn {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 0;
  text-align: center;
  font-weight: 700;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition);
}
.section-alt .letter-btn { background: var(--bg); }
.letter-btn:hover {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

/* ── Theme Grid ── */
.theme-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 10px;
}
.theme-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px;
  text-align: center;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition);
  text-transform: capitalize;
}
.theme-card:hover { background: var(--primary-light); color: var(--primary-dark); border-color: var(--primary); }

/* ── Name Cards ── */
.name-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 16px;
}
.name-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  cursor: pointer;
  transition: all var(--transition);
  box-shadow: var(--shadow-sm);
}
.section-alt .name-card { background: var(--bg); }
.name-card:hover {
  border-color: var(--primary);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}
.name-card-header {
  display: flex;
  justify-content: space-between;
  align-items: start;
  margin-bottom: 8px;
}
.name-card-name { font-family: 'Playfair Display', serif; font-size: 1.4rem; font-weight: 700; }
.name-card-gender {
  font-size: 0.7rem;
  padding: 2px 8px;
  border-radius: 999px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.gender-male { background: #dbeafe; color: #1e40af; }
.gender-female { background: #fce7f3; color: #be185d; }
.gender-unisex { background: #e0e7ff; color: #4338ca; }
.name-card-meaning {
  font-size: 0.9rem;
  color: var(--text-secondary);
  line-height: 1.5;
  margin-bottom: 8px;
}
.name-card-origin {
  font-size: 0.8rem;
  color: var(--primary-dark);
  font-weight: 600;
}

.loading-text {
  text-align: center;
  color: var(--text-muted);
  font-style: italic;
  grid-column: 1 / -1;
  padding: 40px;
}

/* ── Ad Placement ── */
.ad-placeholder {
  background: var(--surface);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  padding: 20px;
  text-align: center;
  min-height: 100px;
}

/* ── Footer ── */
.site-footer {
  background: #1a1a2e;
  color: #d1d5db;
  padding: 56px 0 24px;
  margin-top: 64px;
}
.footer-grid {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 1fr;
  gap: 32px;
  margin-bottom: 40px;
}
.footer-col h4 {
  color: white;
  font-family: 'Inter', sans-serif;
  font-size: 0.95rem;
  font-weight: 700;
  margin-bottom: 16px;
  text-transform: uppercase;
  letter-spacing: 1px;
}
.footer-col a {
  display: block;
  color: #9ca3af;
  font-size: 0.9rem;
  padding: 4px 0;
}
.footer-col a:hover { color: white; }
.footer-col p { color: #9ca3af; font-size: 0.9rem; }
.footer-bottom {
  text-align: center;
  border-top: 1px solid #374151;
  padding-top: 24px;
  color: #6b7280;
  font-size: 0.85rem;
}

/* ── Name Detail Page ── */
.name-detail {
  max-width: 820px;
  margin: 48px auto;
  background: var(--surface);
  border-radius: var(--radius);
  padding: 48px;
  box-shadow: var(--shadow);
}
.name-detail h1 {
  font-size: 3.5rem;
  margin-bottom: 8px;
}
.name-detail .pronunciation {
  color: var(--text-secondary);
  font-size: 1.1rem;
  font-style: italic;
  margin-bottom: 24px;
}
.name-detail .field {
  margin-bottom: 24px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--border);
}
.name-detail .field:last-child { border-bottom: none; }
.name-detail .field-label {
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
  margin-bottom: 8px;
}
.name-detail .field-value { font-size: 1.05rem; line-height: 1.7; }
.theme-tag {
  display: inline-block;
  background: var(--primary-light);
  color: var(--primary-dark);
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 600;
  margin: 2px 4px 2px 0;
  text-transform: capitalize;
}

/* ── Browse Page ── */
.browse-layout {
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: 32px;
  margin: 48px 0;
}
.browse-filters {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  height: fit-content;
  position: sticky;
  top: 80px;
}
.filter-group { margin-bottom: 20px; }
.filter-group-title {
  font-weight: 700;
  margin-bottom: 10px;
  font-size: 0.9rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
}
.filter-option {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 0;
  cursor: pointer;
  font-size: 0.9rem;
}
.filter-option input[type="checkbox"] { cursor: pointer; }

/* ── Article Page ── */
.article {
  max-width: 760px;
  margin: 48px auto;
  background: var(--surface);
  padding: 48px;
  border-radius: var(--radius);
}
.article h1 { font-size: 2.4rem; margin-bottom: 12px; }
.article-meta { color: var(--text-muted); font-size: 0.9rem; margin-bottom: 32px; }
.article h2 { font-size: 1.6rem; margin: 32px 0 16px; }
.article h3 { font-size: 1.25rem; margin: 24px 0 12px; }
.article p { margin-bottom: 16px; line-height: 1.8; color: var(--text); }
.article ul, .article ol { margin: 16px 0; padding-left: 24px; }
.article li { margin-bottom: 8px; }
.article strong { color: var(--text); font-weight: 700; }

/* ── Mobile ── */
@media (max-width: 768px) {
  .hero h1 { font-size: 2rem; }
  .hero-subtitle { font-size: 1rem; }
  .hero-stats { gap: 20px; flex-wrap: wrap; }
  .section { padding: 40px 0; }
  .section-title { font-size: 1.5rem; }
  .main-nav { gap: 16px; font-size: 0.85rem; }
  .main-nav a { font-size: 0.85rem; }
  .footer-grid { grid-template-columns: 1fr 1fr; }
  .letter-grid { grid-template-columns: repeat(7, 1fr); }
  .browse-layout { grid-template-columns: 1fr; }
  .name-detail { padding: 24px; }
  .article { padding: 24px; }
  .search-box { flex-direction: column; }
  .search-box button { width: 100%; }
}

@media (max-width: 480px) {
  .culture-grid { grid-template-columns: 1fr 1fr; }
  .name-cards { grid-template-columns: 1fr; }
  .footer-grid { grid-template-columns: 1fr; }
}
