/* ==========================================================================
   TOPDODUNG.COM - MODERN DESIGN SYSTEM v3 (2026)
   Enhanced: dark mode + animations + better UX
   ========================================================================== */

/* === DESIGN TOKENS === */
:root {
  /* Brand colors */
  --brand-50:  #fff7ed;
  --brand-100: #ffedd5;
  --brand-200: #fed7aa;
  --brand-300: #fdba74;
  --brand-400: #fb923c;
  --brand-500: #f97316;
  --brand-600: #ea580c;
  --brand-700: #c2410c;
  --gray-50:  #f9fafb;
  --gray-100: #f3f4f6;
  --gray-200: #e5e7eb;
  --gray-300: #d1d5db;
  --gray-400: #9ca3af;
  --gray-500: #6b7280;
  --gray-600: #4b5563;
  --gray-700: #374151;
  --gray-800: #1f2937;
  --gray-900: #111827;
  /* Semantic */
  --bg:        #ffffff;
  --bg-muted:  #f9fafb;
  --bg-card:   #ffffff;
  --fg:        #111827;
  --fg-muted:  #6b7280;
  --border:    #e5e7eb;
  /* Spacing scale */
  --space-1: 0.25rem;  --space-2: 0.5rem;  --space-3: 0.75rem;
  --space-4: 1rem;    --space-5: 1.25rem;  --space-6: 1.5rem;
  --space-8: 2rem;    --space-10: 2.5rem;  --space-12: 3rem;
  --space-16: 4rem;   --space-20: 5rem;
  /* Radius */
  --r-sm: 0.375rem;  --r-md: 0.5rem;   --r-lg: 0.75rem;
  --r-xl: 1rem;     --r-2xl: 1.5rem;  --r-full: 9999px;
  /* Shadows */
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow:   0 4px 6px -1px rgb(0 0 0 / 0.1);
  --shadow-md: 0 10px 15px -3px rgb(0 0 0 / 0.1);
  --shadow-lg: 0 20px 25px -5px rgb(0 0 0 / 0.1);
  --shadow-xl: 0 25px 50px -12px rgb(0 0 0 / 0.25);
  /* Transitions */
  --t-fast: 150ms ease;
  --t-base: 250ms ease;
  --t-slow: 350ms ease;
  --t-spring: 500ms cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* Dark mode (auto + toggle support) */
:root.dark {
  --bg:       #0a0a0a;
  --bg-muted: #171717;
  --bg-card:  #171717;
  --fg:       #fafafa;
  --fg-muted: #a1a1a1;
  --border:   #262626;
}
@media (prefers-color-scheme: dark) {
  :root:not(.light) {
    --bg:       #0a0a0a;
    --bg-muted: #171717;
    --bg-card:  #171717;
    --fg:       #fafafa;
    --fg-muted: #a1a3b8;
    --border:   #262626;
  }
}

/* === RESET === */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--fg);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  font-feature-settings: 'cv11', 'ss01', 'cv02';
}
img, svg { max-width: 100%; height: auto; display: block; }
a { color: var(--brand-600); text-decoration: none; transition: color var(--t-fast); }
a:hover { color: var(--brand-700); }

/* === LAYOUT === */
.container { max-width: 1200px; margin: 0 auto; padding: 0 var(--space-6); }
.section { padding: var(--space-16) 0; }
.stack { display: flex; flex-direction: column; gap: var(--space-4); }
.cluster { display: flex; align-items: center; gap: var(--space-3); }
.between { display: flex; align-items: center; justify-content: space-between; }
.grid { display: grid; gap: var(--space-6); }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 1024px) { .grid-3, .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 640px) { .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; } }

/* === TYPOGRAPHY === */
h1, h2, h3, h4, h5 { font-family: 'Inter', system-ui, sans-serif; font-weight: 700; line-height: 1.15; letter-spacing: -0.02em; }
h1 { font-size: clamp(2.5rem, 5vw, 3.5rem); }
h2 { font-size: clamp(1.75rem, 3vw, 2.25rem); }
h3 { font-size: 1.25rem; }
.text-sm { font-size: 0.875rem; }
.text-lg { font-size: 1.125rem; }
.text-xl { font-size: 1.5rem; }
.text-muted { color: var(--fg-muted); }
.text-center { text-align: center; }
.font-bold { font-weight: 700; }
.font-semibold { font-weight: 600; }
.font-extrabold { font-weight: 800; }

/* === HEADER === */
.site-header {
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  border-bottom: 1px solid var(--border);
  padding: var(--space-4) 0;
  position: sticky; top: 0; z-index: 50;
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
}
.site-header .container { display: flex; align-items: center; justify-content: space-between; }
.site-logo {
  font-weight: 800; font-size: 1.25rem;
  color: var(--brand-600);
  letter-spacing: -0.03em;
  text-decoration: none;
  transition: transform var(--t-fast);
}
.site-logo:hover { transform: scale(1.02); }
.site-nav { display: flex; gap: var(--space-6); align-items: center; }
.site-nav a {
  color: var(--fg);
  font-weight: 500;
  font-size: 0.95rem;
  position: relative;
}
.site-nav a:hover { color: var(--brand-600); }
.site-nav a::after {
  content: '';
  position: absolute;
  bottom: -4px; left: 0;
  width: 0; height: 2px;
  background: var(--brand-600);
  transition: width var(--t-base);
}
.site-nav a:hover::after { width: 100%; }

/* === HERO === */
.hero {
  position: relative;
  background: linear-gradient(135deg, var(--brand-500) 0%, var(--brand-700) 100%);
  color: white;
  padding: var(--space-20) var(--space-6);
  text-align: center;
  overflow: hidden;
  isolation: isolate;
}
.hero::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 20% 50%, rgba(255,255,255,0.15), transparent 40%),
    radial-gradient(circle at 80% 80%, rgba(255,255,255,0.1), transparent 50%);
  z-index: -1;
}
.hero::after {
  content: '';
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.5), transparent);
}
.hero h1 {
  color: white;
  font-size: clamp(2.5rem, 6vw, 4rem);
  margin-bottom: var(--space-4);
  letter-spacing: -0.03em;
  animation: slideUp 0.8s var(--t-spring) backwards;
}
.hero p {
  font-size: 1.125rem;
  max-width: 640px;
  margin: 0 auto var(--space-8);
  opacity: 0.95;
  animation: slideUp 0.8s var(--t-spring) 0.1s backwards;
}
.hero-cta {
  display: inline-flex;
  gap: var(--space-3);
  justify-content: center;
  animation: slideUp 0.8s var(--t-spring) 0.2s backwards;
}
@keyframes slideUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

/* === CARDS === */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  padding: var(--space-6);
  transition: transform var(--t-base), box-shadow var(--t-base), border-color var(--t-base);
}
.card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-md);
  border-color: var(--brand-200);
}
.card-link {
  display: block;
  color: inherit;
  text-decoration: none;
  transition: transform var(--t-base);
}
.card-link:hover { transform: translateY(-2px); }

/* === BUTTONS === */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-6);
  border-radius: var(--r-lg);
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  border: none;
  text-decoration: none;
  transition: all var(--t-fast);
  white-space: nowrap;
}
.btn-primary {
  background: var(--brand-600);
  color: white;
  box-shadow: var(--shadow-sm);
}
.btn-primary:hover {
  background: var(--brand-700);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}
.btn-primary:active { transform: translateY(0); }
.btn-outline {
  background: transparent;
  color: var(--brand-600);
  border: 2px solid var(--brand-600);
}
.btn-outline:hover {
  background: var(--brand-600);
  color: white;
}
.btn-lg {
  padding: var(--space-4) var(--space-8);
  font-size: 1rem;
}
.btn-sm {
  padding: var(--space-2) var(--space-4);
  font-size: 0.875rem;
}

/* === BADGES === */
.badge {
  display: inline-flex;
  align-items: center;
  padding: var(--space-1) var(--space-3);
  border-radius: var(--r-full);
  font-size: 0.75rem;
  font-weight: 600;
  background: var(--brand-100);
  color: var(--brand-800);
  letter-spacing: 0.02em;
}
.badge-top { background: #fef3c7; color: #92400e; }
@media (prefers-color-scheme: dark) {
  :root:not(.light) .badge { background: var(--brand-900); color: var(--brand-200); }
  :root:not(.light) .badge-top { background: #422006; color: #fbbf24; }
}

/* === STARS === */
.stars { color: #fbbf24; letter-spacing: 1px; font-size: 0.95rem; line-height: 1; }
.stars .empty { color: var(--gray-300); }
@media (prefers-color-scheme: dark) {
  :root:not(.light) .stars .empty { color: var(--gray-600); }
}

/* === TABLES === */
.compare-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  border-radius: var(--r-lg);
  overflow: hidden;
  border: 1px solid var(--border);
}
.compare-table th, .compare-table td {
  padding: var(--space-3) var(--space-4);
  text-align: left;
}
.compare-table th {
  background: var(--bg-muted);
  font-weight: 600;
  font-size: 0.875rem;
  color: var(--fg-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.compare-table tr + tr td { border-top: 1px solid var(--border); }
.compare-table tbody tr { transition: background var(--t-fast); }
.compare-table tbody tr:hover td { background: var(--bg-muted); }

/* === DISCLOSURE === */
.disclosure {
  background: #fffbeb;
  border: 1px solid #fde68a;
  border-left: 4px solid #f59e0b;
  padding: var(--space-4);
  border-radius: var(--r-md);
  font-size: 0.875rem;
  margin: var(--space-6) 0;
}
@media (prefers-color-scheme: dark) {
  :root:not(.light) .disclosure {
    background: #422006;
    border-color: #92400e;
    color: #fbbf24;
  }
}

/* === CATEGORIES GRID === */
.cat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: var(--space-4);
}
.cat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: var(--space-4);
  text-align: center;
  text-decoration: none;
  color: inherit;
  transition: all var(--t-base);
}
.cat-card:hover {
  border-color: var(--brand-400);
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}
.cat-card:hover .emoji { transform: scale(1.1); }
.cat-card .emoji {
  font-size: 2.5rem;
  margin-bottom: var(--space-2);
  transition: transform var(--t-base);
  display: inline-block;
}

/* === SCORE BREAKDOWN === */
.score-breakdown {
  background: linear-gradient(135deg, var(--brand-50) 0%, transparent 50%);
  border: 1px solid var(--brand-200);
  border-radius: var(--r-xl);
  padding: var(--space-6);
  margin: var(--space-6) 0;
}
.score-circle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: var(--brand-600);
  color: white;
  font-weight: 800;
  font-size: 1.5rem;
  margin: 0 auto;
  box-shadow: var(--shadow-md);
}

/* === DETAILS/SUMMARY (FAQ Accordion) === */
details.faq {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: var(--space-4) var(--space-6);
  margin-bottom: var(--space-3);
  cursor: pointer;
  transition: border-color var(--t-fast);
}
details.faq:hover { border-color: var(--brand-300); }
details.faq[open] { border-color: var(--brand-400); padding-bottom: var(--space-6); }
details.faq summary {
  font-weight: 600;
  padding: var(--space-2) 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  list-style: none;
  cursor: pointer;
}
details.faq summary::-webkit-details-marker { display: none; }
details.faq summary::after {
  content: '+';
  font-size: 1.5rem;
  font-weight: 300;
  color: var(--fg-muted);
  transition: transform var(--t-base);
}
details.faq[open] summary::after { transform: rotate(45deg); }
details.faq p {
  color: var(--fg-muted);
  margin-top: var(--space-3);
  font-size: 0.95rem;
  line-height: 1.7;
}

/* === FILTER/SEARCH (smart features) === */
.search-bar {
  display: flex;
  max-width: 600px;
  margin: 0 auto var(--space-8);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--r-full);
  padding: var(--space-2) var(--space-2) var(--space-2) var(--space-5);
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--t-base), border-color var(--t-base);
}
.search-bar:focus-within {
  box-shadow: var(--shadow-md);
  border-color: var(--brand-400);
}
.search-bar input {
  flex: 1;
  border: none;
  background: transparent;
  font-size: 1rem;
  outline: none;
  font-family: inherit;
  color: var(--fg);
}
.search-bar input::placeholder { color: var(--fg-muted); }
.search-bar button {
  background: var(--brand-600);
  color: white;
  border: none;
  padding: var(--space-2) var(--space-4);
  border-radius: var(--r-full);
  font-weight: 500;
  cursor: pointer;
  font-size: 0.9rem;
}

/* === DARK MODE TOGGLE === */
.theme-toggle {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--r-full);
  width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 1rem;
  transition: all var(--t-fast);
}
.theme-toggle:hover { border-color: var(--brand-400); }

/* === ANIMATIONS === */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
.fade-in { animation: fadeIn 0.5s ease-out backwards; }
.stagger-1 { animation-delay: 0.1s; }
.stagger-2 { animation-delay: 0.2s; }
.stagger-3 { animation-delay: 0.3s; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation: none !important;
    transition: none !important;
  }
}

/* === FOOTER === */
.site-footer {
  background: var(--bg-muted);
  border-top: 1px solid var(--border);
  padding: var(--space-12) 0 var(--space-8);
  margin-top: var(--space-16);
  text-align: center;
  font-size: 0.875rem;
  color: var(--fg-muted);
}
.site-footer a { color: var(--fg-muted); text-decoration: underline; text-decoration-color: var(--gray-300); }
.site-footer a:hover { color: var(--brand-600); }

/* === RESPONSIVE === */
@media (max-width: 640px) {
  .container { padding: 0 var(--space-4); }
  .hero { padding: var(--space-12) var(--space-4); }
  .hero h1 { font-size: 2rem; }
  .site-nav { gap: var(--space-3); font-size: 0.875rem; }
  .cat-grid { grid-template-columns: repeat(2, 1fr); }
  .search-bar { margin: 0 0 var(--space-6); }
}

/* === ACCESSIBILITY === */
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}
:focus-visible { outline: 2px solid var(--brand-500); outline-offset: 2px; border-radius: var(--r-sm); }
.skip-link {
  position: absolute; top: -100px; left: 0;
  background: var(--brand-600); color: white; padding: var(--space-3) var(--space-6);
  z-index: 100;
  text-decoration: none;
  border-radius: var(--r-md);
}
.skip-link:focus { top: 0; }
