/* ===========================================================
   AI Explainer India — Design System
   Apple-grade minimalist aesthetic, pure CSS, zero dependencies.
   =========================================================== */

:root {
  --bg: #ffffff;
  --surface: #f5f5f7;
  --surface-hover: #ececee;
  --text-primary: #1d1d1f;
  --text-secondary: #6e6e73;
  --accent: #0071e3;
  --accent-hover: #0077ed;
  --border: rgba(0, 0, 0, 0.08);
  --shadow: rgba(0, 0, 0, 0.08);
  --header-bg: rgba(255, 255, 255, 0.8);
  --code-bg: #1d1d1f;
  --code-text: #f5f5f7;
  --success: #1db954;
  --max-width: 1100px;
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
}

/* Dark mode: system preference (only applies when user hasn't chosen manually) */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #000000;
    --surface: #1c1c1e;
    --surface-hover: #2c2c2e;
    --text-primary: #f5f5f7;
    --text-secondary: #a1a1a6;
    --accent: #0a84ff;
    --accent-hover: #3aa0ff;
    --border: rgba(255, 255, 255, 0.12);
    --shadow: rgba(0, 0, 0, 0.4);
    --header-bg: rgba(18, 18, 20, 0.8);
    --code-bg: #0a0a0a;
    --code-text: #f5f5f7;
  }
}

/* Dark mode: explicit user choice (wins over system preference) */
:root[data-theme="dark"] {
  --bg: #000000;
  --surface: #1c1c1e;
  --surface-hover: #2c2c2e;
  --text-primary: #f5f5f7;
  --text-secondary: #a1a1a6;
  --accent: #0a84ff;
  --accent-hover: #3aa0ff;
  --border: rgba(255, 255, 255, 0.12);
  --shadow: rgba(0, 0, 0, 0.4);
  --header-bg: rgba(18, 18, 20, 0.8);
  --code-bg: #0a0a0a;
  --code-text: #f5f5f7;
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Noto Sans",
    "Noto Sans Tamil", "Noto Sans Telugu", "Noto Sans Devanagari", sans-serif;
  color: var(--text-primary);
  background: var(--bg);
  line-height: 1.65;
  overflow-x: hidden;
  transition: background-color 0.2s ease, color 0.2s ease;
}

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

img, svg { max-width: 100%; display: block; }

a { color: inherit; }

.container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 20px;
}

/* ---------- Reading progress bar ---------- */
.reading-progress {
  position: fixed;
  top: 0; left: 0;
  height: 3px;
  width: 0%;
  background: var(--accent);
  z-index: 100;
  transition: width 0.1s linear;
}

/* ---------- Header (Apple glass) ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--header-bg);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid var(--border);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  gap: 16px;
}

.logo {
  font-weight: 700;
  font-size: 1.2rem;
  letter-spacing: -0.02em;
  text-decoration: none;
  color: var(--text-primary);
  white-space: nowrap;
}

.logo span { color: var(--accent); }

.site-nav {
  display: flex;
  align-items: center;
  gap: 4px;
}

.site-nav a {
  display: flex;
  align-items: center;
  min-height: 48px;
  padding: 0 12px;
  color: var(--text-secondary);
  text-decoration: none;
  font-weight: 500;
  font-size: 0.95rem;
  border-radius: var(--radius-sm);
  transition: color 0.15s ease, background-color 0.15s ease;
}

.site-nav a:hover { color: var(--accent); background: var(--surface); }

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 1.15rem;
  transition: background-color 0.15s ease, transform 0.15s ease;
}

.icon-btn:hover { background: var(--surface); }
.icon-btn:active { transform: scale(0.92); }

/* ---------- Hero ---------- */
.hero {
  background: var(--surface);
  padding: clamp(48px, 8vw, 96px) 0;
  text-align: center;
}

.hero h1 {
  font-size: clamp(2rem, 5vw, 3.25rem);
  letter-spacing: -0.02em;
  line-height: 1.1;
  margin: 0 0 16px;
  font-weight: 700;
}

.hero p {
  color: var(--text-secondary);
  max-width: 620px;
  margin: 0 auto;
  font-size: clamp(1rem, 2vw, 1.2rem);
}

/* ---------- Search & filter bar ---------- */
.filter-bar {
  padding: 32px 0 0;
}

.search-input-wrap {
  position: relative;
  margin-bottom: 16px;
}

.search-input {
  width: 100%;
  min-height: 48px;
  padding: 0 16px;
  font-size: 1rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-primary);
  outline: none;
  transition: box-shadow 0.15s ease, border-color 0.15s ease;
}

.search-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 20%, transparent);
}

.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 8px;
}

.tag-pill {
  min-height: 40px;
  padding: 0 16px;
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-secondary);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.tag-pill:hover { background: var(--surface-hover); }

.tag-pill.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.no-results {
  display: none;
  text-align: center;
  padding: 48px 0;
  color: var(--text-secondary);
}

.no-results.visible { display: block; }

/* ---------- Articles list / card grid ---------- */
.articles-list { padding: 40px 0 56px; }

.articles-list h2 {
  margin-bottom: 20px;
  letter-spacing: -0.01em;
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 320px), 1fr));
  gap: 20px;
}

.card {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  background: var(--bg);
  transition: box-shadow 0.25s ease, transform 0.25s ease, border-color 0.25s ease;
}

.card:hover {
  box-shadow: 0 12px 32px var(--shadow);
  transform: translateY(-3px);
}

.card a {
  display: block;
  min-height: 48px;
  padding: 22px;
  text-decoration: none;
  color: inherit;
}

.card h3 {
  margin: 0 0 8px;
  font-size: 1.1rem;
  letter-spacing: -0.01em;
  color: var(--text-primary);
}

.card p {
  color: var(--text-secondary);
  font-size: 0.95rem;
  margin: 0 0 14px;
}

.card-tags {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}

.card-tag {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  padding: 3px 8px;
  border-radius: 999px;
}

.read-more {
  color: var(--accent);
  font-weight: 600;
  font-size: 0.9rem;
}

/* ---------- Article page ---------- */
.article-page {
  padding: 40px 0 72px;
  max-width: 720px;
  margin: 0 auto;
}

.article-page .meta {
  color: var(--text-secondary);
  font-size: 0.9rem;
  margin-bottom: 8px;
}

.article-page h1 {
  font-size: clamp(1.75rem, 4vw, 2.5rem);
  letter-spacing: -0.02em;
  line-height: 1.15;
  margin: 0 0 24px;
}

.article-page h2 {
  margin-top: 40px;
  letter-spacing: -0.01em;
  font-size: clamp(1.25rem, 2.5vw, 1.5rem);
}

.article-page p, .article-page li {
  font-size: 1.05rem;
  color: var(--text-primary);
}

.share-row {
  display: flex;
  gap: 10px;
  margin: 24px 0;
  flex-wrap: wrap;
}

.share-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 48px;
  padding: 0 20px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-primary);
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  text-decoration: none;
  transition: background-color 0.15s ease, transform 0.15s ease;
}

.share-btn:hover { background: var(--surface-hover); }
.share-btn:active { transform: scale(0.97); }

.share-btn.whatsapp { color: #25d366; border-color: color-mix(in srgb, #25d366 40%, var(--border)); }

/* Video embed */
.video-embed {
  position: relative;
  width: 100%;
  padding-bottom: 56.25%;
  height: 0;
  margin: 24px 0;
  border-radius: var(--radius-md);
  overflow: hidden;
  background: #000;
}

.video-embed iframe {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  border: 0;
}

.video-credit {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-top: -12px;
  margin-bottom: 24px;
}

.video-credit a { color: var(--accent); }

/* Prompt copy component */
.prompt-copy {
  position: relative;
  background: var(--code-bg);
  color: var(--code-text);
  border-radius: var(--radius-md);
  padding: 20px 56px 20px 20px;
  margin: 20px 0;
  font-family: "SFMono-Regular", Consolas, Menlo, monospace;
  font-size: 0.92rem;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
}

.prompt-copy-btn {
  position: absolute;
  top: 12px;
  right: 12px;
  min-width: 48px;
  min-height: 40px;
  padding: 0 14px;
  border: none;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.15s ease;
}

.prompt-copy-btn:hover { background: rgba(255, 255, 255, 0.22); }
.prompt-copy-btn.copied { background: var(--success); }

/* FAQ */
.faq-item { margin-bottom: 20px; }
.faq-item h3 { font-size: 1.05rem; margin: 0 0 6px; }
.faq-item p { color: var(--text-secondary); margin: 0; }

/* ---------- Ad slots (zero-CLS) ---------- */
.ad-slot {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface);
  border: 1px dashed var(--border);
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-size: 0.75rem;
  overflow: hidden;
  margin: 28px auto;
}

.ad-slot-header {
  max-width: 728px;
  min-height: 50px;
}

.ad-slot-mid {
  max-width: 336px;
  min-height: 280px;
}

.ad-slot-sidebar {
  max-width: 300px;
  min-height: 600px;
}

@media (min-width: 768px) {
  .ad-slot-header { min-height: 90px; }
}

/* ---------- Legal / simple content pages ---------- */
.legal-page { max-width: 760px; }
.legal-page h2 { margin-top: 32px; }
.legal-page ul { padding-left: 20px; }

/* ---------- Footer ---------- */
.site-footer {
  border-top: 1px solid var(--border);
  padding: 32px 0;
  text-align: center;
  color: var(--text-secondary);
  font-size: 0.85rem;
}

.footer-links {
  display: flex;
  justify-content: center;
  gap: 16px;
  flex-wrap: wrap;
  margin-top: 10px;
}

.footer-links a { color: var(--text-secondary); text-decoration: none; }
.footer-links a:hover { color: var(--accent); }

/* ---------- Responsive tweaks ---------- */
@media (max-width: 640px) {
  .header-inner { padding: 10px 16px; flex-wrap: wrap; row-gap: 6px; justify-content: center; }
  .header-inner .logo { flex: 0 0 100%; text-align: center; }
  .site-nav a { padding: 0 8px; font-size: 0.88rem; }
  .hero { padding: 40px 0; }
}

@media (min-width: 1024px) {
  .container { padding: 0 32px; }
}
