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

:root {
  --bg: #f8fafc;
  --bg-gradient: linear-gradient(135deg, #fdfbfb 0%, #ebedee 100%);
  --surface: rgba(255, 255, 255, 0.75);
  --surface-2: rgba(241, 245, 249, 0.8);
  --border: rgba(226, 232, 240, 0.6);
  --text: #0f172a;
  --text-dim: #64748b;
  --accent: #8b5cf6;
  --accent-gradient: linear-gradient(135deg, #6366f1, #a855f7, #ec4899);
  --radius: 16px;
  --shadow: 0 4px 20px rgba(0, 0, 0, 0.05);
  --shadow-hover: 0 10px 30px rgba(139, 92, 246, 0.15);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f172a;
    --bg-gradient: radial-gradient(circle at top left, #1e1b4b 0%, #0f172a 100%);
    --surface: rgba(30, 41, 59, 0.7);
    --surface-2: rgba(51, 65, 85, 0.6);
    --border: rgba(71, 85, 105, 0.4);
    --text: #f8fafc;
    --text-dim: #94a3b8;
    --accent: #a855f7;
    --shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    --shadow-hover: 0 10px 30px rgba(168, 85, 247, 0.3);
  }
}

:root[data-theme="dark"] {
  --bg: #0f172a;
  --bg-gradient: radial-gradient(circle at top left, #1e1b4b 0%, #0f172a 100%);
  --surface: rgba(30, 41, 59, 0.7);
  --surface-2: rgba(51, 65, 85, 0.6);
  --border: rgba(71, 85, 105, 0.4);
  --text: #f8fafc;
  --text-dim: #94a3b8;
  --accent: #a855f7;
  --shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
  --shadow-hover: 0 10px 30px rgba(168, 85, 247, 0.3);
}

* { box-sizing: border-box; }

.site-footer {
  max-width: 1100px;
  margin: 3rem auto 0;
  padding: 1.5rem 1.5rem 2rem;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem;
  color: var(--text-dim);
  font-size: 0.85rem;
}

body {
  margin: 0;
  font-family: 'Outfit', -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg-gradient);
  background-attachment: fixed;
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}

a { color: var(--accent); text-decoration: none; transition: color 0.2s ease; }
a:hover { color: #f472b6; }

header.site {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 2rem;
  border-bottom: 1px solid var(--border);
  gap: 1rem;
  flex-wrap: wrap;
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--surface);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  box-shadow: 0 2px 15px rgba(0,0,0,0.02);
}

header.site .brand { 
  font-weight: 800; 
  font-size: 1.4rem; 
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: -0.03em;
}

header.site nav { display: flex; align-items: center; }
header.site nav a { 
  margin-left: 1.5rem; 
  color: var(--text-dim); 
  font-weight: 500;
  position: relative;
}
header.site nav a:hover { color: var(--text); text-decoration: none; }
header.site nav a::after {
  content: '';
  position: absolute;
  width: 0;
  height: 2px;
  display: block;
  margin-top: 5px;
  right: 0;
  background: var(--accent-gradient);
  transition: width 0.3s ease;
  -webkit-transition: width 0.3s ease;
}
header.site nav a:hover::after {
  width: 100%;
  left: 0;
  background: var(--accent-gradient);
}


#theme-toggle {
  margin-left: 1.5rem;
  width: 2.5rem;
  height: 2.5rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text-dim);
  cursor: pointer;
  font-size: 1.2rem;
  transition: all 0.3s ease;
}
#theme-toggle:hover { 
  color: var(--text); 
  border-color: var(--accent); 
  transform: rotate(15deg) scale(1.1);
}

main { max-width: 1000px; margin: 0 auto; padding: 2rem 1.5rem; }

h1 {
  font-weight: 800;
  letter-spacing: -0.04em;
  margin-bottom: 2rem;
}

.card {
  background: var(--surface);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  margin-bottom: 1.25rem;
  box-shadow: var(--shadow);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.3s cubic-bezier(0.4, 0, 0.2, 1), border-color 0.3s ease;
  animation: fadeSlideUp 0.6s ease-out forwards;
  opacity: 0;
  transform: translateY(20px);
}

a.card { display: block; }
a.card:hover { 
  transform: translateY(-6px); 
  box-shadow: var(--shadow-hover); 
  border-color: rgba(139, 92, 246, 0.3);
  text-decoration: none;
}

.grid { 
  display: grid; 
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); 
  gap: 1.5rem; 
}

.badge {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0.2rem 0.65rem;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text-dim);
  border: 1px solid var(--border);
  transition: transform 0.2s ease, filter 0.2s ease;
}
a.card:hover .badge { transform: scale(1.05); }

.badge.beginner { color: #10b981; border-color: rgba(16, 185, 129, 0.3); background: rgba(16, 185, 129, 0.05); }
.badge.intermediate { color: #0ea5e9; border-color: rgba(14, 165, 233, 0.3); background: rgba(14, 165, 233, 0.05); }
.badge.advanced { color: #ec4899; border-color: rgba(236, 72, 153, 0.3); background: rgba(236, 72, 153, 0.05); }
.badge.scenario { color: #f59e0b; border-color: rgba(245, 158, 11, 0.3); background: rgba(245, 158, 11, 0.05); }
.badge.planned { color: var(--text-dim); }

.topic-title { 
  font-weight: 700; 
  font-size: 1.25rem; 
  margin: 0 0 0.5rem; 
  letter-spacing: -0.01em;
}
.topic-desc { color: var(--text-dim); font-size: 0.95rem; margin: 0 0 1rem; line-height: 1.5; }

.progress-bar {
  height: 6px;
  border-radius: 999px;
  background: var(--surface-2);
  overflow: hidden;
  box-shadow: inset 0 1px 3px rgba(0,0,0,0.1);
}
.progress-bar > span { 
  display: block; 
  height: 100%; 
  background: var(--accent-gradient); 
  border-radius: 999px;
}

.question-block { 
  border-top: 1px solid var(--border); 
  padding-top: 1.5rem; 
  margin-top: 1.5rem; 
}
.question-block:first-child { border-top: none; padding-top: 0; margin-top: 0; }
.question-text { 
  font-weight: 700; 
  font-size: 1.15rem;
  margin: 0.75rem 0 1rem; 
  color: var(--text);
  line-height: 1.4;
}

.answer-body pre { 
  background: #111827; 
  padding: 1.25rem; 
  border-radius: 12px; 
  overflow-x: auto; 
  margin: 1.25rem 0;
  box-shadow: inset 0 2px 10px rgba(0,0,0,0.3);
}
.answer-body code { 
  background: var(--surface-2); 
  padding: 0.15rem 0.4rem; 
  border-radius: 6px; 
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: 0.9em;
  color: #ec4899;
}
.answer-body pre code { background: none; padding: 0; color: #e2e8f0; font-size: 0.95em; }
.answer-body table { border-collapse: collapse; width: 100%; margin: 1.25rem 0; border-radius: 8px; overflow: hidden; }
.answer-body th, .answer-body td { border: 1px solid var(--border); padding: 0.75rem 1rem; text-align: left; }
.answer-body th { background: var(--surface-2); font-weight: 600; }

.followup { margin-top: 1.5rem; padding-left: 1.5rem; border-left: 3px solid var(--accent); background: rgba(139, 92, 246, 0.03); padding: 1rem 1.5rem; border-radius: 0 12px 12px 0; }
.followup .question-text { font-size: 1.05rem; }

.tabs { display: flex; gap: 0.75rem; margin-bottom: 2rem; flex-wrap: wrap; }
.tabs button {
  background: var(--surface-2);
  border: 1px solid transparent;
  color: var(--text-dim);
  padding: 0.6rem 1.25rem;
  border-radius: 999px;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 600;
  transition: all 0.2s ease;
  font-family: 'Outfit', sans-serif;
}
.tabs button:hover { background: var(--border); color: var(--text); }
.tabs button.active { 
  background: var(--accent-gradient); 
  color: white; 
  box-shadow: 0 4px 15px rgba(139, 92, 246, 0.4);
  transform: translateY(-2px);
}

input[type="search"] {
  width: 100%;
  padding: 1rem 1.25rem;
  border-radius: var(--radius);
  border: 2px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 1.1rem;
  font-family: 'Outfit', sans-serif;
  transition: all 0.3s ease;
  box-shadow: var(--shadow);
}
input[type="search"]:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(139, 92, 246, 0.15);
}

.muted { color: var(--text-dim); font-size: 0.95rem; }
.empty-state { color: var(--text-dim); padding: 3rem 0; text-align: center; font-size: 1.1rem; }

/* Progress & Focus */
.mastered-btn, .focus-btn {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-dim);
  border-radius: 999px;
  padding: 0.3rem 0.8rem;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  margin-left: 0.75rem;
  vertical-align: middle;
  transition: all 0.2s ease;
  font-family: 'Outfit', sans-serif;
}
.mastered-btn:hover, .focus-btn:hover {
  background: var(--surface-2);
  color: var(--text);
  transform: translateY(-1px);
}
.mastered-btn.is-mastered {
  background: var(--accent-gradient);
  color: white;
  border: none;
  box-shadow: 0 2px 10px rgba(16, 185, 129, 0.3);
}
.question-block.is-mastered {
  opacity: 0.55;
  filter: grayscale(0.4);
  transition: opacity 0.3s ease, filter 0.3s ease;
}
.question-block.is-mastered:hover {
  opacity: 1;
  filter: grayscale(0);
}

/* Focus mode overlay */
#focus-modal {
  display: flex;
  visibility: hidden;
  opacity: 0;
  position: fixed;
  top: 0; left: 0; width: 100%; height: 100%;
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  z-index: 1000;
  overflow-y: auto;
  padding: 2rem;
  align-items: flex-start;
  justify-content: center;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}
#focus-modal.active {
  visibility: visible;
  opacity: 1;
}
#focus-close {
  position: fixed;
  top: 1.5rem; right: 2rem;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 999px;
  padding: 0.6rem 1.5rem;
  cursor: pointer;
  z-index: 1001;
  font-weight: 600;
  font-family: 'Outfit', sans-serif;
  transition: all 0.2s ease;
  box-shadow: var(--shadow);
}
#focus-close:hover {
  background: var(--surface-2);
  transform: scale(1.05);
}
.focus-content {
  max-width: 850px;
  width: 100%;
  margin: 3rem auto;
  background: var(--surface);
  padding: 3rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
  transform: scale(0.95) translateY(20px);
  transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  opacity: 0;
}
#focus-modal.active .focus-content {
  transform: scale(1) translateY(0);
  opacity: 1;
}
.focus-content .question-text {
  font-size: 1.75rem;
  line-height: 1.3;
}

/* Animations */
@keyframes fadeSlideUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Utility to add delays for staggered animations */
.delay-1 { animation-delay: 0.05s; }
.delay-2 { animation-delay: 0.1s; }
.delay-3 { animation-delay: 0.15s; }
.delay-4 { animation-delay: 0.2s; }
.delay-5 { animation-delay: 0.25s; }
.delay-6 { animation-delay: 0.3s; }
.delay-7 { animation-delay: 0.35s; }
.delay-8 { animation-delay: 0.4s; }
.delay-9 { animation-delay: 0.45s; }
.delay-10 { animation-delay: 0.5s; }
