/* ============================================
   OpenClaw Learning Hub — Redesigned
   Modern Editorial Academic Style
   ============================================ */

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

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

/* --- Theme Variables --- */
:root, [data-theme="light"] {
  --bg-base: #faf8f4;
  --bg-card: #ffffff;
  --bg-header: #1a3a2e;
  --bg-code: #0d1b2a;
  --bg-callout-info: #e8f5f1;
  --bg-callout-tip: #fff4e6;
  --bg-callout-warn: #fef3e2;
  --text-primary: #1a2e26;
  --text-secondary: #4a5f58;
  --text-muted: #7a8d86;
  --text-inverse: #faf8f4;
  --border: #d8e2dd;
  --border-accent: #b8936a;
  --shadow-sm: 0 2px 8px rgba(26,58,46,0.08);
  --shadow-md: 0 8px 24px rgba(26,58,46,0.12);
  --shadow-hover: 0 16px 48px rgba(26,58,46,0.2);
  --radius: 4px;
  --radius-lg: 8px;
  --color-primary: #1a3a2e;
  --color-accent: #d4a574;
  --color-accent-bright: #e8b17f;
  --color-warning: #d97706;
  --color-info: #0891b2;
  --color-success: #059669;
  --gradient-hero: linear-gradient(135deg, #1a3a2e 0%, #2d5a47 100%);
  --gradient-card: linear-gradient(180deg, rgba(212,165,116,0.03) 0%, rgba(212,165,116,0) 100%);
}

[data-theme="dark"] {
  --bg-base: #0f1612;
  --bg-card: #1a2520;
  --bg-header: #0a1410;
  --bg-code: #050a08;
  --bg-callout-info: #1a2e26;
  --bg-callout-tip: #2a2214;
  --bg-callout-warn: #2a1f10;
  --text-primary: #e8f0ed;
  --text-secondary: #a8c0b8;
  --text-muted: #6a7d76;
  --text-inverse: #faf8f4;
  --border: #2a3a34;
  --border-accent: #8a6d4f;
  --shadow-sm: 0 2px 8px rgba(0,0,0,0.3);
  --shadow-md: 0 8px 24px rgba(0,0,0,0.4);
  --shadow-hover: 0 16px 48px rgba(0,0,0,0.6);
  --gradient-card: linear-gradient(180deg, rgba(212,165,116,0.05) 0%, rgba(212,165,116,0) 100%);
}

/* --- Base --- */
html {
  font-size: 17px;
  scroll-behavior: smooth;
}

body {
  font-family: 'IBM Plex Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  color: var(--text-primary);
  background: var(--bg-base);
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  position: relative;
  transition: background 0.4s cubic-bezier(0.4, 0, 0.2, 1), color 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Subtle noise texture */
body::before {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  opacity: 0.03;
  z-index: 1;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 400 400' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noiseFilter'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='4' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noiseFilter)'/%3E%3C/svg%3E");
}

a {
  color: var(--color-accent);
  text-decoration: none;
  transition: color 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}
a:hover { color: var(--color-accent-bright); }

/* --- Typography --- */
h1, h2, h3, .site-title, .article-title, .card-title {
  font-family: 'Crimson Pro', Georgia, serif;
  font-weight: 700;
  letter-spacing: -0.02em;
}

/* --- Code --- */
code {
  font-family: 'IBM Plex Mono', 'SF Mono', 'Consolas', monospace;
  font-size: 0.88em;
  background: var(--bg-code);
  color: #a8dadc;
  padding: 3px 8px;
  border-radius: 3px;
}

pre {
  background: var(--bg-code);
  color: #cbd5e1;
  padding: 24px;
  border-radius: var(--radius);
  overflow-x: auto;
  font-size: 0.88rem;
  line-height: 1.6;
  margin: 20px 0;
  border-left: 3px solid var(--color-accent);
}
pre code {
  background: none;
  padding: 0;
  color: inherit;
}

/* --- Layout --- */
.page-wrapper {
  max-width: 1260px;
  margin: 0 auto;
  padding: 0 32px;
  position: relative;
  z-index: 2;
}

/* ============================================
   THEME TOGGLE
   ============================================ */
.topbar {
  position: fixed;
  top: 24px;
  right: 32px;
  z-index: 100;
}

.theme-toggle {
  background: var(--bg-card);
  border: 2px solid var(--border);
  width: 48px;
  height: 48px;
  border-radius: 50%;
  font-size: 20px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-sm);
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.3s;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}
.theme-toggle:hover {
  transform: scale(1.15) rotate(15deg);
  box-shadow: var(--shadow-md);
  border-color: var(--color-accent);
}

/* ============================================
   INDEX PAGE
   ============================================ */

/* --- Header --- */
.index-header {
  background: var(--gradient-hero);
  padding: 120px 0 80px;
  margin: 0 -32px 60px;
  position: relative;
  overflow: hidden;
}
.index-header::before {
  content: '';
  position: absolute;
  top: -40%;
  right: -20%;
  width: 80%;
  height: 140%;
  background: radial-gradient(ellipse at 60% 50%, rgba(212,165,116,0.15) 0%, transparent 70%);
  pointer-events: none;
}
.index-header::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 2px;
  background: linear-gradient(90deg, transparent 0%, var(--color-accent) 50%, transparent 100%);
}
.header-content {
  position: relative;
  z-index: 1;
  text-align: center;
}

.site-title {
  font-size: 4.2rem;
  font-weight: 900;
  color: var(--text-inverse);
  margin-bottom: 12px;
  letter-spacing: -0.03em;
  line-height: 1.1;
  text-shadow: 0 4px 16px rgba(0,0,0,0.3);
}
.site-subtitle {
  color: rgba(250,248,244,0.8);
  font-size: 1.15rem;
  margin-bottom: 40px;
  font-weight: 500;
  letter-spacing: 0.02em;
}

/* --- Search --- */
.search-wrapper {
  position: relative;
  max-width: 580px;
  margin: 0 auto;
}
.search-input {
  width: 100%;
  padding: 18px 56px 18px 24px;
  border-radius: 50px;
  border: 2px solid rgba(250,248,244,0.2);
  background: rgba(250,248,244,0.12);
  color: var(--text-inverse);
  font-size: 1.05rem;
  outline: none;
  font-family: 'IBM Plex Sans', sans-serif;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
.search-input::placeholder { 
  color: rgba(250,248,244,0.6); 
}
.search-input:focus {
  background: rgba(250,248,244,0.2);
  border-color: var(--color-accent);
  box-shadow: 0 0 0 4px rgba(212,165,116,0.2);
}
.search-icon {
  position: absolute;
  right: 24px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 20px;
  pointer-events: none;
  opacity: 0.8;
}

/* --- Category Pills --- */
.filter-section { 
  padding: 0 0 40px; 
}
.category-pills {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: center;
}
.pill {
  padding: 10px 24px;
  border-radius: 50px;
  border: 2px solid var(--border);
  background: var(--bg-card);
  color: var(--text-secondary);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: var(--shadow-sm);
  letter-spacing: 0.01em;
}
.pill:hover {
  border-color: var(--color-accent);
  color: var(--color-primary);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}
.pill.active {
  background: var(--color-primary);
  color: var(--text-inverse);
  border-color: var(--color-primary);
  box-shadow: 0 4px 16px rgba(26,58,46,0.3);
}

/* --- Articles Grid --- */
.articles-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
  gap: 28px;
  padding: 0 0 80px;
}

/* --- Article Card --- */
.article-card {
  background: var(--bg-card);
  background-image: var(--gradient-card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
  padding: 32px;
  text-decoration: none;
  color: var(--text-primary);
  display: flex;
  flex-direction: column;
  gap: 14px;
  transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
  cursor: pointer;
  position: relative;
  overflow: hidden;
  animation: fadeInUp 0.6s cubic-bezier(0.16, 1, 0.3, 1) both;
}
.article-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 3px;
  background: linear-gradient(90deg, var(--card-accent, var(--color-accent)) 0%, transparent 100%);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.article-card:hover {
  transform: translateY(-6px) rotate(0.5deg);
  box-shadow: var(--shadow-hover);
  border-color: var(--border-accent);
}
.article-card:hover::before {
  transform: scaleX(1);
}

.card-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
}
.card-topic-badge {
  font-size: 0.8rem;
  font-weight: 700;
  padding: 6px 14px;
  border-radius: 50px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.card-read-time {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 500;
}
.card-title {
  font-size: 1.5rem;
  font-weight: 700;
  line-height: 1.25;
  color: var(--text-primary);
  margin-bottom: 4px;
}
.card-subtitle {
  font-size: 0.95rem;
  color: var(--text-secondary);
  line-height: 1.6;
  flex-grow: 1;
}
.card-tags {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 4px;
}
.card-footer {
  margin-top: auto;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}
.card-date {
  font-size: 0.82rem;
  color: var(--text-muted);
  font-weight: 500;
}

/* --- Tags --- */
.tag {
  display: inline-block;
  font-size: 0.78rem;
  font-weight: 600;
  padding: 4px 12px;
  border-radius: 50px;
  background: var(--bg-callout-info);
  color: var(--color-info);
  border: 1px solid transparent;
  transition: all 0.2s;
}
.tag:hover {
  border-color: var(--color-info);
}

/* --- Empty State --- */
.empty-state {
  text-align: center;
  padding: 80px 0;
  color: var(--text-secondary);
  font-size: 1.1rem;
  font-weight: 500;
}

/* --- Site Footer --- */
.site-footer {
  text-align: center;
  padding: 40px 0 48px;
  color: var(--text-muted);
  font-size: 0.88rem;
  border-top: 1px solid var(--border);
  margin-top: 40px;
}

/* ============================================
   ARTICLE PAGE
   ============================================ */

.article-page { 
  padding-top: 40px; 
}

/* --- Breadcrumb --- */
.breadcrumb {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-bottom: 24px;
  flex-wrap: wrap;
  font-weight: 500;
}
.breadcrumb a { 
  color: var(--text-secondary); 
  transition: color 0.2s;
}
.breadcrumb a:hover { 
  color: var(--color-accent); 
}
.breadcrumb .sep { 
  color: var(--text-muted); 
  opacity: 0.5;
}
.breadcrumb .current { 
  color: var(--text-primary); 
  font-weight: 600; 
}

/* --- Article Hero --- */
.article-hero {
  background: var(--bg-card);
  background-image: var(--gradient-card);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  border-top: 4px solid var(--color-accent);
  padding: 48px;
  margin-bottom: 28px;
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
}
.article-hero::after {
  content: '';
  position: absolute;
  bottom: -50%;
  right: -20%;
  width: 60%;
  height: 100%;
  background: radial-gradient(ellipse, rgba(212,165,116,0.06) 0%, transparent 70%);
  pointer-events: none;
}
.article-meta {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 20px;
  flex-wrap: wrap;
  position: relative;
  z-index: 1;
}
.topic-badge {
  font-size: 0.85rem;
  font-weight: 700;
  padding: 6px 16px;
  border-radius: 50px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.article-title {
  font-size: 3rem;
  font-weight: 900;
  line-height: 1.15;
  color: var(--text-primary);
  margin-bottom: 14px;
  letter-spacing: -0.03em;
  position: relative;
  z-index: 1;
}
.article-subtitle {
  font-size: 1.2rem;
  color: var(--text-secondary);
  margin-bottom: 20px;
  line-height: 1.5;
  position: relative;
  z-index: 1;
}
.article-info {
  display: flex;
  gap: 24px;
  font-size: 0.9rem;
  color: var(--text-muted);
  font-weight: 500;
  position: relative;
  z-index: 1;
}

/* --- Article Content --- */
.article-content {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  padding: 56px;
  box-shadow: var(--shadow-sm);
  line-height: 1.8;
}
.article-content h2 {
  font-size: 2rem;
  font-weight: 700;
  color: var(--text-primary);
  margin: 48px 0 20px;
  padding-bottom: 12px;
  border-bottom: 2px solid var(--border-accent);
  position: relative;
}
.article-content h2:first-child { margin-top: 0; }
.article-content h2::before {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 0;
  width: 60px;
  height: 2px;
  background: var(--color-accent);
}

.article-content h3 {
  font-size: 1.4rem;
  font-weight: 600;
  color: var(--text-primary);
  margin: 32px 0 16px;
}
.article-content p {
  color: var(--text-secondary);
  margin-bottom: 18px;
  font-size: 1.05rem;
}
.article-content ul,
.article-content ol {
  margin: 16px 0 24px 32px;
  color: var(--text-secondary);
}
.article-content li { 
  margin-bottom: 10px; 
  font-size: 1.05rem;
}
.article-content strong { 
  color: var(--text-primary); 
  font-weight: 600;
}

/* --- Callout --- */
.callout {
  border-left: 4px solid var(--color-info);
  border-radius: 0 var(--radius) var(--radius) 0;
  padding: 20px 24px;
  margin: 28px 0;
  background: var(--bg-callout-info);
  box-shadow: var(--shadow-sm);
}
.callout-title {
  font-weight: 700;
  font-size: 0.95rem;
  margin-bottom: 8px;
  color: var(--color-info);
  letter-spacing: 0.01em;
}
.callout p { 
  margin: 0 !important; 
  font-size: 0.98rem; 
}

.callout.tip {
  border-left-color: var(--color-accent);
  background: var(--bg-callout-tip);
}
.callout.tip .callout-title { color: var(--color-accent); }

.callout.warning {
  border-left-color: var(--color-warning);
  background: var(--bg-callout-warn);
}
.callout.warning .callout-title { color: var(--color-warning); }

/* --- Code Block --- */
.code-block { 
  margin: 24px 0; 
}
.code-label {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 8px;
  font-family: 'IBM Plex Sans', sans-serif;
}
.code-block pre { 
  margin-top: 0; 
}

/* --- Article Nav --- */
.article-nav {
  padding: 40px 0 60px;
  display: flex;
  align-items: center;
}
.btn-back {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 14px 28px;
  background: var(--bg-card);
  border: 2px solid var(--border);
  border-radius: 50px;
  color: var(--text-secondary);
  font-size: 0.95rem;
  font-weight: 600;
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  box-shadow: var(--shadow-sm);
}
.btn-back:hover {
  background: var(--color-primary);
  color: var(--text-inverse);
  border-color: var(--color-primary);
  box-shadow: var(--shadow-md);
  transform: translateX(-4px);
}

/* ============================================
   ANIMATIONS
   ============================================ */
@keyframes fadeInUp {
  from { 
    opacity: 0; 
    transform: translateY(24px); 
  }
  to { 
    opacity: 1; 
    transform: translateY(0); 
  }
}

/* Staggered delays */
.article-card:nth-child(1) { animation-delay: 0s; }
.article-card:nth-child(2) { animation-delay: 0.1s; }
.article-card:nth-child(3) { animation-delay: 0.2s; }
.article-card:nth-child(4) { animation-delay: 0.3s; }
.article-card:nth-child(5) { animation-delay: 0.4s; }
.article-card:nth-child(6) { animation-delay: 0.5s; }
.article-card:nth-child(7) { animation-delay: 0.6s; }
.article-card:nth-child(8) { animation-delay: 0.7s; }
.article-card:nth-child(9) { animation-delay: 0.8s; }

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 768px) {
  html { font-size: 16px; }
  .page-wrapper { padding: 0 20px; }
  .index-header { 
    padding: 80px 0 60px; 
    margin: 0 -20px 40px; 
  }
  .site-title { font-size: 2.8rem; }
  .articles-grid { 
    grid-template-columns: 1fr; 
    gap: 20px;
  }
  .article-hero { padding: 32px 24px; }
  .article-content { padding: 32px 24px; }
  .article-title { font-size: 2.2rem; }
}

@media (max-width: 480px) {
  .site-title { font-size: 2.2rem; }
  .search-input { 
    font-size: 0.95rem; 
    padding: 16px 52px 16px 20px; 
  }
  .article-content { padding: 28px 20px; }
  .article-hero { padding: 28px 20px; }
  .article-title { font-size: 1.8rem; }
}
