/* ============================================
   IAS WAR — UPSC Strategic Intelligence App
   Military-Editorial Aesthetic
   ============================================ */

:root {
  --bg-primary: #f5f2ec;
  --bg-secondary: #edeae2;
  --bg-card: #ffffff;
  --bg-card-hover: #faf8f4;
  --accent-gold: #9a7230;
  --accent-red: #b83232;
  --accent-green: #2a7d4f;
  --accent-blue: #2563a8;
  --text-primary: #1e1c18;
  --text-secondary: #4a4640;
  --text-muted: #8a8070;
  --border: #ddd8cc;
  --border-accent: #c8c0b0;
  --font-display: 'Playfair Display', Georgia, serif;
  --font-mono: 'IBM Plex Mono', 'Courier New', monospace;
  --font-body: 'Source Serif 4', Georgia, serif;
  --shadow-card: 0 2px 16px rgba(0,0,0,0.08);
  --shadow-glow: 0 0 20px rgba(154,114,48,0.12);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  background: var(--bg-primary);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.6;
  min-height: 100vh;
  background-image: 
    radial-gradient(ellipse at 20% 0%, rgba(154,114,48,0.05) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 100%, rgba(184,50,50,0.04) 0%, transparent 50%);
}

/* ---- HEADER ---- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(245,242,236,0.96);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-accent);
}

.header-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 12px 20px;
  display: flex;
  align-items: center;
  gap: 20px;
  flex-wrap: wrap;
}

.logo-block {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.logo-icon {
  font-size: 28px;
  filter: sepia(1) saturate(3) brightness(0.9);
}

.logo-title {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 900;
  letter-spacing: 4px;
  color: var(--accent-gold);
  line-height: 1;
}

.logo-sub {
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 2px;
  color: var(--text-secondary);
  text-transform: uppercase;
  margin-top: 2px;
}

.top-nav {
  display: flex;
  gap: 4px;
  flex: 1;
  flex-wrap: wrap;
}

.nav-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-secondary);
  padding: 8px 14px;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 1px;
  cursor: pointer;
  border-radius: 4px;
  transition: all 0.2s;
  white-space: nowrap;
}

.nav-btn:hover, .nav-btn.active {
  background: var(--accent-gold);
  border-color: var(--accent-gold);
  color: #000;
  font-weight: 600;
}

.refresh-btn {
  background: var(--accent-red);
  border: none;
  color: #fff;
  padding: 8px 16px;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 2px;
  cursor: pointer;
  border-radius: 4px;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

.refresh-btn:hover { background: #a93226; transform: scale(1.02); }
.refresh-btn.spinning .refresh-icon { animation: spin 1s linear infinite; }

@keyframes spin { to { transform: rotate(360deg); } }

/* ---- TICKER ---- */
.ticker-bar {
  display: flex;
  align-items: center;
  border-top: 1px solid var(--border);
  background: rgba(154,114,48,0.07);
  overflow: hidden;
  height: 32px;
}

.ticker-label {
  background: var(--accent-gold);
  color: #000;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 1px;
  padding: 0 12px;
  height: 100%;
  display: flex;
  align-items: center;
  white-space: nowrap;
  flex-shrink: 0;
}

.ticker-track {
  flex: 1;
  overflow: hidden;
  position: relative;
}

.ticker-content {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--accent-gold);
  white-space: nowrap;
  animation: tickerScroll 30s linear infinite;
  display: inline-block;
  padding-left: 100%;
}

@keyframes tickerScroll {
  from { transform: translateX(0); }
  to { transform: translateX(-100%); }
}

/* ---- MAIN LAYOUT ---- */
.main-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px 20px;
}

/* ---- STATS BAR ---- */
.stats-bar {
  display: flex;
  align-items: center;
  background: var(--bg-card);
  border: 1px solid var(--border-accent);
  border-radius: 8px;
  padding: 16px 24px;
  margin-bottom: 28px;
  gap: 0;
  flex-wrap: wrap;
}

.stat-item {
  flex: 1;
  min-width: 80px;
  text-align: center;
}

.stat-num {
  display: block;
  font-family: var(--font-display);
  font-size: 28px;
  font-weight: 700;
  color: var(--accent-gold);
  line-height: 1;
}

.stat-label {
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 1px;
  color: var(--text-secondary);
  text-transform: uppercase;
  margin-top: 4px;
  display: block;
}

.stat-divider {
  width: 1px;
  height: 40px;
  background: var(--border);
  margin: 0 8px;
}

/* ---- TAB SECTIONS ---- */
.tab-section { display: none; }
.tab-section.active { display: block; }

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
  flex-wrap: wrap;
  gap: 12px;
}

.section-title {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 2px;
  color: var(--text-primary);
  position: relative;
  padding-left: 16px;
}

.section-title::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 4px;
  height: 70%;
  background: var(--accent-gold);
  border-radius: 2px;
}

.section-meta {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
}

.section-desc {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 4px;
}

/* ---- NEWS GRID ---- */
.news-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 20px;
}

.news-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  transition: all 0.25s;
  cursor: pointer;
  position: relative;
  animation: fadeUp 0.4s ease both;
}

.news-card:hover {
  background: var(--bg-card-hover);
  border-color: var(--accent-gold);
  transform: translateY(-3px);
  box-shadow: var(--shadow-glow);
}

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

.news-card-ribbon {
  height: 3px;
  background: linear-gradient(90deg, var(--accent-red), var(--accent-gold));
}

.news-card-body {
  padding: 18px;
}

.news-source {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 2px;
  color: var(--accent-gold);
  text-transform: uppercase;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.news-source-dot {
  width: 6px;
  height: 6px;
  background: var(--accent-red);
  border-radius: 50%;
  display: inline-block;
  animation: blink 2s ease infinite;
}

@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

.news-title {
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 700;
  line-height: 1.4;
  color: var(--text-primary);
  margin-bottom: 10px;
}

.news-desc {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.6;
  margin-bottom: 14px;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.news-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
}

.news-date {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-muted);
}

.news-actions {
  display: flex;
  gap: 6px;
}

.action-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-secondary);
  padding: 4px 10px;
  font-family: var(--font-mono);
  font-size: 10px;
  cursor: pointer;
  border-radius: 3px;
  transition: all 0.2s;
}

.action-btn:hover {
  border-color: var(--accent-gold);
  color: var(--accent-gold);
}

.news-tag {
  display: inline-block;
  background: rgba(192,57,43,0.15);
  border: 1px solid rgba(192,57,43,0.3);
  color: #e74c3c;
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 1px;
  padding: 2px 8px;
  border-radius: 2px;
  text-transform: uppercase;
  margin-bottom: 8px;
}

/* ---- MCQ ---- */
.mcq-list { display: flex; flex-direction: column; gap: 20px; }

.mcq-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 22px;
  transition: all 0.2s;
  animation: fadeUp 0.4s ease both;
}

.mcq-number {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 2px;
  color: var(--accent-gold);
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.mcq-difficulty {
  padding: 2px 8px;
  border-radius: 3px;
  font-size: 9px;
  letter-spacing: 1px;
}
.diff-easy { background: rgba(46,204,113,0.15); color: var(--accent-green); border: 1px solid rgba(46,204,113,0.3); }
.diff-medium { background: rgba(52,152,219,0.15); color: var(--accent-blue); border: 1px solid rgba(52,152,219,0.3); }
.diff-hard { background: rgba(192,57,43,0.15); color: #e74c3c; border: 1px solid rgba(192,57,43,0.3); }

.mcq-question {
  font-family: var(--font-body);
  font-size: 15px;
  color: var(--text-primary);
  margin-bottom: 16px;
  line-height: 1.6;
}

.mcq-options {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 14px;
}

.mcq-option {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 5px;
  cursor: pointer;
  transition: all 0.2s;
  background: transparent;
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 14px;
  text-align: left;
  line-height: 1.5;
}

.mcq-option:hover:not(:disabled) {
  border-color: var(--accent-gold);
  background: rgba(154,114,48,0.06);
}

.mcq-option.correct {
  border-color: var(--accent-green);
  background: rgba(46,204,113,0.1);
  color: var(--accent-green);
}

.mcq-option.wrong {
  border-color: var(--accent-red);
  background: rgba(192,57,43,0.1);
  color: #e74c3c;
}

.mcq-option:disabled { cursor: default; }

.option-label {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 600;
  color: var(--accent-gold);
  flex-shrink: 0;
}

.mcq-explanation {
  background: rgba(154,114,48,0.07);
  border: 1px solid rgba(154,114,48,0.2);
  border-radius: 5px;
  padding: 12px 16px;
  font-size: 13px;
  color: var(--text-secondary);
  display: none;
  line-height: 1.6;
}

.mcq-explanation.visible { display: block; }

.mcq-explanation strong {
  color: var(--accent-gold);
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 1px;
  display: block;
  margin-bottom: 4px;
}

/* ---- MAINS ---- */
.mains-list { display: flex; flex-direction: column; gap: 24px; }

.mains-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  animation: fadeUp 0.4s ease both;
}

.mains-card-head {
  padding: 18px 22px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.mains-meta {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}

.mains-badge {
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 1px;
  padding: 3px 8px;
  border-radius: 3px;
}
.badge-gs2 { background: rgba(52,152,219,0.15); color: var(--accent-blue); border: 1px solid rgba(52,152,219,0.3); }
.badge-gs3 { background: rgba(46,204,113,0.15); color: var(--accent-green); border: 1px solid rgba(46,204,113,0.3); }
.badge-essay { background: rgba(154,114,48,0.12); color: var(--accent-gold); border: 1px solid rgba(154,114,48,0.3); }
.badge-marks { background: rgba(255,255,255,0.05); color: var(--text-secondary); border: 1px solid var(--border); }

.mains-question {
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.5;
}

.toggle-answer-btn {
  background: transparent;
  border: 1px solid var(--accent-gold);
  color: var(--accent-gold);
  padding: 6px 14px;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 1px;
  cursor: pointer;
  border-radius: 4px;
  white-space: nowrap;
  transition: all 0.2s;
  flex-shrink: 0;
}

.toggle-answer-btn:hover, .toggle-answer-btn.shown {
  background: var(--accent-gold);
  color: #000;
}

.mains-answer {
  padding: 0 22px;
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.4s ease, padding 0.3s ease;
}

.mains-answer.visible {
  max-height: 1200px;
  padding: 20px 22px;
}

.answer-section {
  margin-bottom: 16px;
}

.answer-section h4 {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 2px;
  color: var(--accent-gold);
  text-transform: uppercase;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.answer-section h4::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

.answer-section p {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.7;
}

.answer-section ul {
  list-style: none;
  padding: 0;
}

.answer-section ul li {
  padding: 4px 0 4px 18px;
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.6;
  position: relative;
}

.answer-section ul li::before {
  content: '▸';
  position: absolute;
  left: 0;
  color: var(--accent-gold);
  font-size: 10px;
}

.key-terms {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.key-term {
  background: rgba(154,114,48,0.08);
  border: 1px solid rgba(154,114,48,0.2);
  color: var(--accent-gold);
  font-family: var(--font-mono);
  font-size: 10px;
  padding: 3px 8px;
  border-radius: 3px;
}

/* ---- SAVED ---- */
.saved-list { display: flex; flex-direction: column; gap: 14px; }

.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}

.empty-icon { font-size: 40px; display: block; margin-bottom: 12px; }

/* ---- MCQ CONTROLS ---- */
.mcq-controls { display: flex; gap: 8px; flex-wrap: wrap; }

.ctrl-btn {
  background: transparent;
  border: 1px solid var(--border-accent);
  color: var(--text-secondary);
  padding: 7px 14px;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 1px;
  cursor: pointer;
  border-radius: 4px;
  transition: all 0.2s;
}

.ctrl-btn:hover {
  border-color: var(--accent-gold);
  color: var(--accent-gold);
}

.ctrl-btn.danger:hover {
  border-color: var(--accent-red);
  color: #e74c3c;
}

/* ---- LOADING ---- */
.loading-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 13px;
}

.loading-state.hidden { display: none; }

.pulse-loader {
  width: 48px;
  height: 48px;
  border: 3px solid var(--border);
  border-top-color: var(--accent-gold);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 16px;
}

/* ---- MODAL ---- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(30,28,24,0.55);
  backdrop-filter: blur(6px);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s;
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: all;
}

.modal-box {
  background: var(--bg-secondary);
  border: 1px solid var(--border-accent);
  border-radius: 10px;
  max-width: 680px;
  width: 100%;
  max-height: 85vh;
  overflow-y: auto;
  padding: 28px;
  position: relative;
  transform: translateY(20px);
  transition: transform 0.25s;
}

.modal-overlay.active .modal-box {
  transform: translateY(0);
}

.modal-close {
  position: absolute;
  top: 16px;
  right: 16px;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-secondary);
  width: 32px;
  height: 32px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 14px;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-close:hover { border-color: var(--accent-red); color: #e74c3c; }

.modal-content h2 {
  font-family: var(--font-display);
  font-size: 20px;
  color: var(--text-primary);
  margin-bottom: 16px;
  padding-right: 40px;
  line-height: 1.4;
}

.modal-content p {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.7;
  margin-bottom: 12px;
}

.modal-content a {
  color: var(--accent-gold);
  text-decoration: none;
  font-family: var(--font-mono);
  font-size: 12px;
}

/* ---- TOAST ---- */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--bg-card);
  border: 1px solid var(--accent-gold);
  color: var(--text-primary);
  padding: 12px 20px;
  border-radius: 6px;
  font-family: var(--font-mono);
  font-size: 12px;
  opacity: 0;
  transform: translateY(10px);
  transition: all 0.25s;
  z-index: 300;
  pointer-events: none;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

/* ---- SAVED ITEM ---- */
.saved-item {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 16px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.saved-item-type {
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 1px;
  color: var(--accent-gold);
  margin-bottom: 4px;
  display: block;
}

.saved-item-title {
  font-size: 14px;
  color: var(--text-primary);
  line-height: 1.5;
}

.saved-remove {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 16px;
  transition: color 0.2s;
  flex-shrink: 0;
  padding: 4px;
}

.saved-remove:hover { color: #e74c3c; }

/* ---- RESPONSIVE ---- */
@media (max-width: 768px) {
  .header-inner {
    padding: 10px 14px;
    gap: 10px;
  }

  .logo-title { font-size: 18px; }

  .top-nav {
    order: 3;
    width: 100%;
    gap: 4px;
  }

  .nav-btn {
    flex: 1;
    padding: 8px 6px;
    font-size: 10px;
    text-align: center;
  }

  .refresh-btn { margin-left: auto; }

  .stats-bar {
    padding: 12px 16px;
    gap: 0;
  }

  .stat-num { font-size: 22px; }
  .stat-label { font-size: 8px; }
  .stat-divider { margin: 0 4px; }

  .news-grid {
    grid-template-columns: 1fr;
    gap: 14px;
  }

  .section-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .mains-card-head {
    flex-direction: column;
  }

  .toggle-answer-btn { align-self: flex-start; }

  .main-container { padding: 16px 14px; }

  .section-title { font-size: 16px; }

  .mcq-option { font-size: 13px; }
}

@media (max-width: 480px) {
  .logo-block { gap: 8px; }
  .logo-icon { font-size: 22px; }
  .logo-title { font-size: 16px; letter-spacing: 2px; }
  .logo-sub { display: none; }
  .stats-bar { flex-wrap: wrap; }
  .stat-item { min-width: 60px; }
}

/* Scrollbar */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg-secondary); }
::-webkit-scrollbar-thumb { background: var(--border-accent); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--accent-gold); }
