/* ===== Nomatize — Design System ===== */

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

:root {
  --primary: #3b82f6;
  --primary-dark: #2563eb;
  --secondary: #10b981;
  --accent: #8b5cf6;
  --bg: #f8fafc;
  --bg-card: #ffffff;
  --text: #0f172a;
  --text-secondary: #64748b;
  --border: #e2e8f0;
  --radius: 1rem;
  --radius-lg: 1.5rem;
  --shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
}

.dark {
  --bg: #020617;
  --bg-card: #0f172a;
  --text: #f1f5f9;
  --text-secondary: #94a3b8;
  --border: #1e293b;
}

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

html {
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  transition: background 0.3s, color 0.3s;
}

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

img { max-width: 100%; height: auto; }

/* ===== Utilities ===== */
.container { width: 100%; max-width: 1200px; margin: 0 auto; padding: 0 1rem; }

.fade-in {
  animation: fadeIn 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

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

.slide-up {
  animation: slideUp 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

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

.scale-in {
  animation: scaleIn 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes scaleIn {
  from { opacity: 0; transform: scale(0.9); }
  to { opacity: 1; transform: scale(1); }
}

/* ===== Header ===== */
.header {
  background: color-mix(in srgb, var(--bg-card) 80%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}

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

.logo {
  font-size: 1.5rem;
  font-weight: 900;
  letter-spacing: -0.03em;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  cursor: pointer;
  user-select: none;
}

/* ===== Nav ===== */
.nav { display: flex; align-items: center; gap: 1.5rem; }

.nav-link {
  color: var(--text-secondary);
  font-weight: 500;
  font-size: 0.875rem;
  cursor: pointer;
  transition: color 0.2s;
  padding: 0.25rem 0;
  border: none;
  background: none;
  position: relative;
}

.nav-link:hover, .nav-link.active { color: var(--primary); }

.nav-link.active::after {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--primary);
  border-radius: 1px;
}

/* ===== Cards ===== */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  transition: box-shadow 0.3s, transform 0.3s;
}

.card:hover {
  box-shadow: var(--shadow-lg);
  transform: translateY(-2px);
}

.card-body { padding: 1.5rem; }

/* ===== Buttons ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.75rem 1.5rem;
  border-radius: 0.75rem;
  font-weight: 700;
  font-size: 0.875rem;
  border: none;
  cursor: pointer;
  transition: all 0.2s;
  text-decoration: none;
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  color: white;
  box-shadow: 0 4px 14px color-mix(in srgb, var(--primary) 30%, transparent);
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px color-mix(in srgb, var(--primary) 40%, transparent);
}

.btn-primary:active { transform: translateY(0) scale(0.98); }

.btn-ghost {
  background: color-mix(in srgb, var(--text) 5%, transparent);
  color: var(--text-secondary);
}

.btn-ghost:hover { background: color-mix(in srgb, var(--text) 10%, transparent); }

.btn-danger { background: #ef4444; color: white; }
.btn-danger:hover { background: #dc2626; }

.btn-sm { padding: 0.5rem 1rem; font-size: 0.8rem; border-radius: 0.5rem; }

/* ===== Forms ===== */
.input {
  width: 100%;
  padding: 0.875rem 1rem;
  border: 2px solid var(--border);
  border-radius: 0.75rem;
  background: var(--bg);
  color: var(--text);
  font-size: 1rem;
  font-family: inherit;
  transition: border-color 0.2s, box-shadow 0.2s;
  outline: none;
}

.input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 20%, transparent);
}

.select {
  appearance: none;
  width: 100%;
  padding: 0.875rem 2.5rem 0.875rem 1rem;
  border: 2px solid var(--border);
  border-radius: 0.75rem;
  background: var(--bg-card) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2364748b' d='M6 8L1 3h10z'/%3E%3C/svg%3E") no-repeat right 1rem center;
  color: var(--text);
  font-size: 0.9rem;
  font-family: inherit;
  font-weight: 500;
  cursor: pointer;
  transition: border-color 0.2s;
  outline: none;
}

.select:focus { border-color: var(--primary); }

/* ===== Tabs ===== */
.tab-btn {
  position: relative;
  border: none;
  background: none;
  cursor: pointer;
  font-weight: 700;
  font-size: 0.9rem;
  padding: 1rem 1.25rem;
  color: var(--text-secondary);
  transition: color 0.2s, background 0.2s;
  white-space: nowrap;
}

.tab-btn:hover { color: var(--text); background: color-mix(in srgb, var(--text) 5%, transparent); }

.tab-btn.active { color: var(--text); }

.tab-btn::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 0;
  height: 3px;
  background: var(--primary);
  border-radius: 3px 3px 0 0;
  transition: width 0.3s;
}

.tab-btn.active::after { width: 80%; }

/* ===== Result ===== */
.result-name {
  font-size: clamp(2rem, 5vw, 4rem);
  font-weight: 900;
  color: var(--text);
  letter-spacing: -0.03em;
  line-height: 1.1;
  word-break: break-word;
}

.result-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.25rem 0.75rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
}

.badge-origin { background: color-mix(in srgb, var(--primary) 15%, transparent); color: var(--primary); }
.badge-syllables { background: color-mix(in srgb, var(--secondary) 15%, transparent); color: var(--secondary); }

/* ===== Glow border ===== */
.glow-border {
  border: 2px solid var(--border);
  border-radius: 1rem;
  transition: border-color 0.3s, box-shadow 0.3s;
}

.glow-border:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 20%, transparent);
}

/* ===== Pulse dots ===== */
.pulse-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}

.pulse-dot.available { background: #10b981; box-shadow: 0 0 6px #10b981; }
.pulse-dot.unavailable { background: #ef4444; box-shadow: 0 0 6px #ef4444; }
.pulse-dot.checking { background: #f59e0b; animation: pulse 1s infinite; }

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* ===== Quiz ===== */
.quiz-option {
  padding: 1rem 1.25rem;
  border: 2px solid var(--border);
  border-radius: 0.75rem;
  cursor: pointer;
  transition: all 0.2s;
  font-weight: 500;
}

.quiz-option:hover {
  border-color: var(--primary);
  background: color-mix(in srgb, var(--primary) 8%, transparent);
}

.quiz-option.selected {
  border-color: var(--primary);
  background: color-mix(in srgb, var(--primary) 15%, transparent);
  color: var(--primary);
}

/* ===== Toast ===== */
.toast {
  position: fixed;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: var(--text);
  color: var(--bg);
  padding: 0.75rem 1.5rem;
  border-radius: 0.75rem;
  font-weight: 600;
  font-size: 0.875rem;
  z-index: 999;
  opacity: 0;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  pointer-events: none;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ===== Scrollbar ===== */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-secondary); }

/* ===== Responsive ===== */
@media (max-width: 768px) {
  .nav-desktop { display: none; }
  .container { padding: 0 0.75rem; }
  .card-body { padding: 1rem; }
}

/* ===== Bottom nav mobile ===== */
.bottom-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: color-mix(in srgb, var(--bg-card) 90%, transparent);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--border);
  z-index: 100;
  padding: 0.5rem;
  justify-content: space-around;
}

@media (max-width: 768px) {
  .bottom-nav { display: flex; }
  body { padding-bottom: 4rem; }
}

.bottom-nav-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.125rem;
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 0.625rem;
  font-weight: 500;
  cursor: pointer;
  padding: 0.25rem 0.5rem;
  transition: color 0.2s;
}

.bottom-nav-btn.active { color: var(--primary); }

.bottom-nav-btn svg { width: 1.25rem; height: 1.25rem; }

/* ===== Favorite heart ===== */
.fav-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-secondary);
  transition: color 0.2s, transform 0.2s;
  padding: 0.5rem;
}

.fav-btn:hover { transform: scale(1.2); }
.fav-btn.active { color: #ef4444; }
.fav-btn.active svg { fill: #ef4444; }

/* ===== Animated heart pop ===== */
@keyframes heartPop {
  0% { transform: scale(1); }
  50% { transform: scale(1.4); }
  100% { transform: scale(1); }
}

.heart-pop { animation: heartPop 0.3s ease; }

/* ===== Skeleton loading ===== */
.skeleton {
  background: linear-gradient(90deg, var(--border) 25%, transparent 50%, var(--border) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: 0.5rem;
}

@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ===== SEO Articles ===== */
.article-content {
  line-height: 1.8;
}

.article-content h1 { font-size: 2rem; margin-bottom: 1rem; }
.article-content h2 { font-size: 1.5rem; margin: 2rem 0 1rem; }
.article-content h3 { font-size: 1.25rem; margin: 1.5rem 0 0.75rem; }
.article-content p { margin-bottom: 1rem; color: var(--text-secondary); }
.article-content ul { margin-bottom: 1rem; padding-left: 1.5rem; }
.article-content li { margin-bottom: 0.5rem; color: var(--text-secondary); }
