/* ==========================================================================
   READER-FIRST COMFORT LIGHT THEME DESIGN SYSTEM
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=Newsreader:ital,opsz,wght@0,6..72,400;0,6..72,600;1,6..72,400&family=JetBrains+Mono:wght@400;500&display=swap');

:root {
  /* Color Palette - Reader First Paper & Ink */
  --bg-paper: #FAF9F6;
  --bg-card: #FFFFFF;
  --bg-subtle: #F1F0EA;
  --bg-hover: #EBE8DF;
  
  --text-ink: #1E293B;
  --text-body: #334155;
  --text-muted: #64748B;
  --text-light: #94A3B8;
  
  --accent-primary: #2563EB;
  --accent-primary-hover: #1D4ED8;
  --accent-secondary: #0D9488;
  --accent-warm: #D97706;
  --accent-highlight: #FEF08A;
  
  --border-color: #E2E8F0;
  --border-dark: #CBD5E1;
  
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.08);
  
  --font-serif: 'Newsreader', Georgia, serif;
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;

  --reading-measure: 720px;
  --font-scale: 1;
}

/* Font Size Modifiers for Reader Comfort */
body.font-sm { --font-scale: 0.9; }
body.font-md { --font-scale: 1; }
body.font-lg { --font-scale: 1.15; }
body.font-xl { --font-scale: 1.3; }

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

html {
  scroll-behavior: smooth;
  font-size: calc(16px * var(--font-scale));
}

body {
  background-color: var(--bg-paper);
  color: var(--text-body);
  font-family: var(--font-sans);
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  transition: background-color 0.3s ease, font-size 0.2s ease;
}

/* Reading Progress Bar */
#reading-progress-container {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 4px;
  background: var(--bg-subtle);
  z-index: 1000;
}

#reading-progress-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent-primary), var(--accent-secondary));
  transition: width 0.1s linear;
}

/* Container */
.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 1.5rem;
}

.reading-container {
  max-width: var(--reading-measure);
  margin: 0 auto;
}

/* Reader Control Bar */
.reader-toolbar {
  position: sticky;
  top: 4px;
  background: rgba(250, 249, 246, 0.92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border-color);
  padding: 0.75rem 0;
  z-index: 900;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.reader-controls {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.btn-icon {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  color: var(--text-ink);
  padding: 0.4rem 0.75rem;
  border-radius: 6px;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  transition: all 0.2s ease;
}

.btn-icon:hover {
  background: var(--bg-hover);
  border-color: var(--border-dark);
}

.btn-icon.active {
  background: var(--text-ink);
  color: var(--bg-card);
  border-color: var(--text-ink);
}

/* Header & Nav */
header {
  padding: 1.5rem 0;
  border-bottom: 1px solid var(--border-color);
}

.nav-wrapper {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  text-decoration: none;
  color: var(--text-ink);
}

.brand-avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 1.1rem;
}

.brand-info h1 {
  font-family: var(--font-sans);
  font-size: 1.15rem;
  font-weight: 700;
  line-height: 1.2;
}

.brand-info p {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.nav-links {
  display: flex;
  list-style: none;
  gap: 1.5rem;
  align-items: center;
}

.nav-link {
  text-decoration: none;
  color: var(--text-muted);
  font-weight: 500;
  font-size: 0.95rem;
  transition: color 0.2s ease;
  padding: 0.4rem 0.2rem;
  border-bottom: 2px solid transparent;
}

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

/* GitHub Star Pill Button */
.github-star-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background: #24292F;
  color: white;
  text-decoration: none;
  padding: 0.45rem 0.9rem;
  border-radius: 20px;
  font-size: 0.85rem;
  font-weight: 600;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.github-star-pill:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.github-star-count {
  background: rgba(255, 255, 255, 0.2);
  padding: 0.15rem 0.45rem;
  border-radius: 10px;
  font-size: 0.75rem;
}

/* Hero Section */
.hero {
  padding: 3.5rem 0 2.5rem;
}

.hero-tag {
  display: inline-block;
  background: #EFF6FF;
  color: var(--accent-primary);
  border: 1px solid #BFDBFE;
  padding: 0.3rem 0.8rem;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 600;
  margin-bottom: 1.25rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.hero-title {
  font-family: var(--font-serif);
  font-size: 2.75rem;
  font-weight: 600;
  color: var(--text-ink);
  line-height: 1.2;
  margin-bottom: 1.25rem;
}

.hero-description {
  font-size: 1.15rem;
  color: var(--text-body);
  margin-bottom: 2rem;
  max-width: 100%;
}

.hero-actions {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  align-items: center;
}

.btn-primary {
  background: var(--accent-primary);
  color: white;
  text-decoration: none;
  padding: 0.75rem 1.5rem;
  border-radius: 8px;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: background-color 0.2s ease;
}

.btn-primary:hover {
  background: var(--accent-primary-hover);
}

.btn-secondary {
  background: var(--bg-card);
  color: var(--text-ink);
  text-decoration: none;
  padding: 0.75rem 1.5rem;
  border-radius: 8px;
  font-weight: 600;
  border: 1px solid var(--border-color);
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-secondary:hover {
  background: var(--bg-hover);
}

/* Sections */
.section {
  padding: 3.5rem 0;
  border-top: 1px solid var(--border-color);
}

.section-header {
  margin-bottom: 2rem;
}

.section-title {
  font-family: var(--font-serif);
  font-size: 2.2rem;
  color: var(--text-ink);
  margin-bottom: 0.5rem;
}

.section-subtitle {
  color: var(--text-muted);
  font-size: 1.05rem;
}

/* Cards & Grid */
.grid-2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 1.5rem;
}

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

.card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 1.5rem;
  box-shadow: var(--shadow-sm);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

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

/* Badge Tags */
.badge {
  display: inline-block;
  padding: 0.2rem 0.6rem;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 600;
  background: var(--bg-subtle);
  color: var(--text-muted);
}

.badge-primary {
  background: #EFF6FF;
  color: var(--accent-primary);
}

.badge-success {
  background: #F0FDF4;
  color: var(--accent-secondary);
}

.badge-warning {
  background: #FFFBEB;
  color: var(--accent-warm);
}

/* Interactive 5-Star Rating Widget */
.rating-widget {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  background: var(--bg-subtle);
  border-radius: 8px;
  margin-top: 1rem;
  border: 1px solid var(--border-color);
}

.rating-stars {
  display: flex;
  gap: 0.25rem;
}

.star-btn {
  background: none;
  border: none;
  font-size: 1.25rem;
  cursor: pointer;
  color: #CBD5E1;
  transition: color 0.15s ease, transform 0.15s ease;
}

.star-btn.active, .star-btn:hover {
  color: #F59E0B;
  transform: scale(1.2);
}

.rating-text {
  font-size: 0.85rem;
  color: var(--text-muted);
  font-weight: 500;
}

/* Modal Reader */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(4px);
  z-index: 2000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}

.modal-overlay.active {
  display: flex;
}

.modal-card {
  background: var(--bg-paper);
  width: 100%;
  max-width: 800px;
  max-height: 90vh;
  border-radius: 16px;
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-lg);
  overflow-y: auto;
  position: relative;
  padding: 2.5rem;
}

.modal-close {
  position: absolute;
  top: 1.25rem;
  right: 1.25rem;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 50%;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 1.1rem;
  color: var(--text-muted);
  transition: all 0.2s ease;
}

.modal-close:hover {
  background: var(--text-ink);
  color: white;
}

/* Reader Mode overrides */
body.reader-mode header,
body.reader-mode .hero,
body.reader-mode footer,
body.reader-mode .non-reader-element {
  display: none !important;
}

body.reader-mode .section {
  border-top: none;
  padding: 1rem 0;
}

/* Footer */
footer {
  padding: 3rem 0;
  border-top: 1px solid var(--border-color);
  background: var(--bg-card);
}

.footer-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1.5rem;
}

/* Responsive */
@media (max-width: 768px) {
  .hero-title { font-size: 2rem; }
  .nav-links { display: none; }
}
