/* =========================================================
   Research Library — Stylesheet
   ========================================================= */


/* ── Design tokens ──────────────────────────────────────── */
:root {
  --navy:         #1a3155;
  --navy-dark:    #111e38;
  --navy-mid:     #243d6a;
  --blue:         #2563eb;
  --blue-hover:   #1d4ed8;
  --blue-light:   #eff6ff;
  --amber:        #b45309;
  --amber-bg:     #fffbeb;
  --amber-border: #fcd34d;
  --bg:           #f1f5f9;
  --card:         #ffffff;
  --text:         #1e293b;
  --muted:        #64748b;
  --border:       #e2e8f0;
  --radius-sm:    8px;
  --radius:       14px;
  --radius-lg:    20px;
  --shadow:       0 1px 3px rgba(0,0,0,.07), 0 4px 12px rgba(0,0,0,.05);
  --shadow-md:    0 4px 12px rgba(0,0,0,.10), 0 8px 28px rgba(0,0,0,.07);
  --transition:   .18s ease;
}


/* ── Reset ──────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; scroll-behavior: smooth; }
body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
img, svg { display: block; }
.sr-only {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}


/* ── Layout ─────────────────────────────────────────────── */
.container { max-width: 1200px; margin: 0 auto; padding: 0 24px; }


/* ── Header ─────────────────────────────────────────────── */
.site-header {
  background: var(--navy-dark);
  position: sticky; top: 0; z-index: 200;
  box-shadow: 0 2px 12px rgba(0,0,0,.25);
}
.header-inner {
  display: flex; align-items: center;
  justify-content: space-between;
  padding-top: 14px; padding-bottom: 14px;
}
.site-brand {
  display: flex; align-items: center; gap: 9px;
  color: #fff; font-size: 1.1rem; font-weight: 700;
  text-decoration: none; letter-spacing: -.01em;
}
.site-brand:hover { color: #e0eaff; text-decoration: none; }
.site-nav a {
  color: rgba(255,255,255,.7); font-size: .875rem;
  text-decoration: none; transition: color var(--transition);
}
.site-nav a:hover { color: #fff; }


/* ── Hero ───────────────────────────────────────────────── */
.hero {
  background: linear-gradient(150deg, var(--navy-dark) 0%, var(--navy-mid) 65%, #2d5499 100%);
  color: #fff;
  padding: 72px 0 60px;
  text-align: center;
}
.hero h1 {
  font-size: clamp(1.6rem, 4vw, 2.6rem);
  font-weight: 700; letter-spacing: -.025em;
  line-height: 1.2; margin-bottom: 14px;
}
.hero-subtitle {
  font-size: clamp(.9rem, 2vw, 1.05rem);
  color: rgba(255,255,255,.72); max-width: 560px;
  margin: 0 auto 36px; line-height: 1.5;
}
.hero-stats {
  margin-top: 20px;
  font-size: .825rem;
  color: rgba(255,255,255,.55);
  display: flex; align-items: center; justify-content: center; gap: 10px;
}
.stat-divider { opacity: .4; }


/* ── Search bar ─────────────────────────────────────────── */
.search-wrapper {
  display: flex; max-width: 640px; margin: 0 auto;
  background: #fff;
  border-radius: 50px;
  box-shadow: 0 6px 32px rgba(0,0,0,.28);
  overflow: hidden;
}
.search-input {
  flex: 1; border: none; outline: none;
  padding: 15px 22px;
  font-size: .975rem; font-family: inherit; color: var(--text);
  background: transparent;
}
.search-input::placeholder { color: #94a3b8; }
.search-btn {
  background: var(--blue); border: none; color: #fff;
  padding: 0 22px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background var(--transition);
  flex-shrink: 0;
}
.search-btn:hover { background: var(--blue-hover); }


/* ── Search results panel ───────────────────────────────── */
.search-results-panel {
  background: var(--card);
  border-bottom: 1px solid var(--border);
  padding: 28px 0;
}
.search-results-panel.hidden { display: none; }


.search-results-header {
  font-size: .83rem; color: var(--muted); margin-bottom: 16px;
}
.search-result-item {
  padding: 16px 0;
  border-bottom: 1px solid var(--border);
}
.search-result-item:last-child { border-bottom: none; }
.search-result-title {
  font-size: .975rem; font-weight: 600;
  color: var(--navy); display: block; margin-bottom: 4px;
}
.search-result-title:hover { color: var(--blue); text-decoration: underline; }
.search-result-meta {
  font-size: .78rem; color: var(--muted); margin-bottom: 8px;
}
.search-result-snippet {
  font-size: .875rem; color: #475569; line-height: 1.65;
}
.search-result-snippet mark {
  background: #fef08a; color: var(--text);
  border-radius: 3px; padding: 0 2px;
}
.search-result-page {
  font-size: .75rem; color: var(--muted); margin-top: 6px;
}
.search-result-link {
  display: inline-block; margin-top: 10px;
  font-size: .8rem; font-weight: 500; color: var(--blue);
}
.search-no-results { padding: 32px 0; text-align: center; color: var(--muted); }
.search-no-results strong { color: var(--text); }
.search-loading {
  padding: 32px 0; text-align: center;
  color: var(--muted); font-size: .9rem;
}


/* ── Library grid section ───────────────────────────────── */
.library-section { padding: 44px 0 72px; }


.articles-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 24px;
}
@media (max-width: 980px) { .articles-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 580px)  { .articles-grid { grid-template-columns: 1fr; } }


/* ── Article card ───────────────────────────────────────── */
.article-card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
  display: flex; flex-direction: column; gap: 10px;
  transition: box-shadow var(--transition), transform var(--transition);
  border: 1px solid transparent;
}
.article-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-3px);
  border-color: var(--border);
}


.card-badges {
  display: flex; flex-wrap: wrap; gap: 7px; align-items: center;
}


/* ── Badges ─────────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center; gap: 3px;
  font-size: .7rem; font-weight: 600; letter-spacing: .01em;
  padding: 3px 10px; border-radius: 20px; white-space: nowrap;
  line-height: 1.4;
}
.badge-amber {
  background: var(--amber-bg); color: var(--amber);
  border: 1px solid var(--amber-border);
}
.badge-gray  { background: #f1f5f9; color: var(--muted); border: 1px solid var(--border); }
.badge-outline { background: transparent; color: var(--muted); border: 1px solid var(--border); }


.card-title {
  font-size: 1rem; font-weight: 600;
  color: var(--navy); line-height: 1.4;
}
.card-title a { color: inherit; text-decoration: none; }
.card-title a:hover { color: var(--blue); text-decoration: underline; }


.card-authors { font-size: .78rem; color: var(--muted); }
.card-journal { font-size: .75rem; font-style: italic; color: var(--muted); }
.card-summary {
  font-size: .855rem; color: #475569; line-height: 1.65; flex: 1;
}
.card-footer {
  display: flex; gap: 10px; margin-top: 6px; flex-wrap: wrap;
}


/* ── Buttons ────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center;
  padding: 8px 16px; border-radius: var(--radius-sm);
  font-size: .825rem; font-weight: 500; font-family: inherit;
  cursor: pointer; border: 1px solid transparent;
  transition: background var(--transition), color var(--transition),
              border-color var(--transition), box-shadow var(--transition);
  text-decoration: none !important; white-space: nowrap;
}
.btn-sm { padding: 5px 12px; font-size: .78rem; }
.btn-primary { background: var(--blue); color: #fff; border-color: var(--blue); }
.btn-primary:hover { background: var(--blue-hover); border-color: var(--blue-hover); }
.btn-ghost {
  background: transparent; color: var(--muted);
  border-color: var(--border);
}
.btn-ghost:hover { color: var(--blue); border-color: var(--blue); }


/* ── Article detail page ────────────────────────────────── */
.article-detail { padding: 40px 0 72px; }


.breadcrumb {
  font-size: .875rem; color: var(--muted); margin-bottom: 24px;
}
.breadcrumb a { color: var(--blue); }


.detail-header {
  background: var(--card);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 36px 40px; margin-bottom: 24px;
}
@media (max-width: 600px) { .detail-header { padding: 24px; } }


.detail-badges {
  display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 18px;
}
.detail-title {
  font-size: clamp(1.2rem, 3vw, 1.65rem);
  font-weight: 700; color: var(--navy);
  line-height: 1.3; margin-bottom: 14px; letter-spacing: -.015em;
}
.detail-authors {
  font-size: .875rem; color: var(--muted);
  margin-bottom: 24px; line-height: 1.6;
}


/* Citation display block */
.detail-citation-block { margin-bottom: 28px; }
.citation-display {
  display: inline-flex; align-items: center; gap: 10px;
  background: var(--amber-bg); border: 1px solid var(--amber-border);
  color: var(--amber); border-radius: var(--radius-sm);
  padding: 12px 20px;
}
.citation-display--zero { background: #f8fafc; border-color: var(--border); color: var(--muted); }
.citation-display--unknown { background: #f8fafc; border-color: var(--border); color: var(--muted); }
.citation-star { font-size: 1.2rem; }
.citation-number { font-size: 1.6rem; font-weight: 700; line-height: 1; }
.citation-label { font-size: .8rem; font-weight: 500; }


.detail-actions { display: flex; gap: 12px; flex-wrap: wrap; }


/* Detail section cards */
.detail-card {
  background: var(--card);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 32px 40px; margin-bottom: 24px;
}
@media (max-width: 600px) { .detail-card { padding: 24px; } }


.detail-card-label {
  display: flex; align-items: center; gap: 7px;
  font-size: .7rem; font-weight: 700;
  letter-spacing: .09em; text-transform: uppercase;
  color: var(--blue); margin-bottom: 18px;
}
.ai-model-tag {
  margin-left: auto;
  background: var(--blue-light); color: var(--blue);
  font-size: .65rem; padding: 2px 8px; border-radius: 20px;
  letter-spacing: .04em; text-transform: none; font-weight: 600;
}


.summary-body p {
  font-size: .975rem; color: #374151; line-height: 1.8;
  margin-bottom: 1.2em;
}
.summary-body p:last-child { margin-bottom: 0; }


/* PDF section */
.detail-card--pdf { padding: 0; overflow: hidden; }
.pdf-toolbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 24px; border-bottom: 1px solid var(--border);
}
.pdf-frame {
  width: 100%; height: 720px;
  border: none; display: block;
}


/* ── Setup / empty state ────────────────────────────────── */
.setup-box {
  max-width: 520px; margin: 56px auto;
  background: var(--card); border-radius: var(--radius);
  padding: 44px; text-align: center; box-shadow: var(--shadow);
}
.setup-icon { font-size: 2.5rem; margin-bottom: 16px; }
.setup-box h2 { font-size: 1.3rem; color: var(--navy); margin-bottom: 12px; }
.setup-box p  { color: var(--muted); font-size: .9rem; line-height: 1.6; margin-bottom: 16px; }
.setup-box p.setup-hint { font-size: .82rem; margin-top: 12px; }
.code-block {
  background: var(--navy-dark); color: #93c5fd;
  padding: 13px 20px; border-radius: var(--radius-sm);
  font-family: 'SF Mono', 'Consolas', 'Menlo', monospace;
  font-size: .9rem; text-align: left;
  margin: 0 0 4px;
}
.setup-box code { font-family: inherit; background: var(--bg); padding: 2px 6px; border-radius: 4px; }


/* ── Footer ─────────────────────────────────────────────── */
.site-footer {
  background: var(--navy-dark); color: rgba(255,255,255,.45);
  text-align: center; padding: 24px 0; font-size: .78rem;
}
.site-footer strong { color: rgba(255,255,255,.65); font-weight: 500; }


/* ── Utilities ──────────────────────────────────────────── */
.hidden { display: none !important; }


/* ── Mode toggle ─────────────────────────────────────────── */
.query-mode-toggle {
  display: flex; justify-content: center; gap: 6px;
  margin-bottom: 14px;
}
.mode-btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 18px; border-radius: 50px;
  border: 1.5px solid rgba(255,255,255,.3);
  background: rgba(255,255,255,.08);
  color: rgba(255,255,255,.72);
  font-size: .85rem; font-weight: 500; font-family: inherit;
  cursor: pointer;
  transition: background var(--transition), color var(--transition),
              border-color var(--transition);
}
.mode-btn:hover {
  background: rgba(255,255,255,.15);
  color: #fff; border-color: rgba(255,255,255,.5);
}
.mode-btn--active {
  background: #fff; color: var(--navy-dark); border-color: #fff;
  font-weight: 600;
}
.mode-btn--active:hover {
  background: rgba(255,255,255,.92); color: var(--navy-dark);
}


/* ── Ask AI panel ────────────────────────────────────────── */
.ask-panel {
  background: var(--card);
  border-bottom: 1px solid var(--border);
  padding: 32px 0;
}


.ask-loading {
  display: flex; align-items: center; gap: 12px;
  color: var(--muted); font-size: .9rem; padding: 8px 0;
}
.ask-spinner {
  width: 20px; height: 20px;
  border: 2.5px solid var(--border);
  border-top-color: var(--blue);
  border-radius: 50%;
  animation: spin .7s linear infinite;
  flex-shrink: 0;
}
@keyframes spin { to { transform: rotate(360deg); } }


.ask-error {
  background: #fef2f2; border: 1px solid #fecaca;
  color: #b91c1c; border-radius: var(--radius-sm);
  padding: 14px 18px; font-size: .875rem;
}


/* Sources */
.ask-sources { margin-bottom: 28px; }
.ask-sources-label {
  font-size: .7rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .09em;
  color: var(--blue); margin-bottom: 12px;
}
.ask-sources-list {
  display: flex; flex-wrap: wrap; gap: 10px;
}
.ask-source-card {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 12px 14px;
  background: var(--blue-light); border: 1px solid #bfdbfe;
  border-radius: var(--radius-sm);
  text-decoration: none !important;
  flex: 1 1 240px; max-width: 340px;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.ask-source-card:hover {
  border-color: var(--blue);
  box-shadow: 0 2px 8px rgba(37,99,235,.12);
}
.ask-source-num {
  width: 22px; height: 22px; flex-shrink: 0;
  background: var(--blue); color: #fff; border-radius: 50%;
  font-size: .72rem; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  margin-top: 1px;
}
.ask-source-body { min-width: 0; }
.ask-source-title {
  font-size: .8rem; font-weight: 600; color: var(--navy);
  line-height: 1.4;
  display: -webkit-box; -webkit-line-clamp: 2;
  -webkit-box-orient: vertical; overflow: hidden;
}
.ask-source-meta {
  font-size: .72rem; color: var(--muted); margin-top: 3px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}


/* Answer */
.ask-answer-label {
  font-size: .7rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .09em;
  color: var(--blue); margin-bottom: 16px;
}
.ask-answer-text {
  font-size: .975rem; color: #374151;
  line-height: 1.85; max-width: 780px;
  white-space: pre-wrap;
}
.ask-answer-text ol,
.ask-answer-text ul {
  white-space: normal;
  padding-left: 1.5rem;
  margin: .6rem 0 .75rem;
}
.ask-answer-text ol { list-style: decimal; }
.ask-answer-text ul { list-style: disc; }
.ask-answer-text li {
  margin: .4rem 0;
  line-height: 1.7;
}
.ask-answer-text p {
  white-space: normal;
  margin: 0 0 .75rem;
}
.ask-answer-text p:first-child { margin-top: 0; }
.ask-answer-text p:last-child  { margin-bottom: 0; }
.ask-answer-text strong { font-weight: 600; color: var(--text); }
.ask-answer-text.streaming::after {
  content: "▌"; color: var(--blue);
  animation: blink .8s step-end infinite;
  margin-left: 1px;
}
@keyframes blink { 0%, 100% { opacity: 1; } 50% { opacity: 0; } }




/* Custom overrides for search layout */
.query-search-group {
  flex-wrap: wrap;
}
.search-wrapper {
  max-width: none;
  margin: 0;
  flex: 1;
}


/* Custom overrides for search layout */
.query-search-group {
  flex-wrap: wrap;
}
.search-wrapper {
  max-width: none;
  margin: 0;
  flex: 1;
}


/* stack search field and buttons vertically on narrow screens */
@media (max-width: 600px) {
  .query-search-group {
    flex-direction: column;
    align-items: stretch;
  }
  .search-wrapper {
    margin-bottom: 0.75rem; /* gap between search field and buttons */
  }
  .query-mode-toggle {
    justify-content: flex-start;
  }
}
/* === Custom palette inspired by BlairGolson.com === */
:root {
  --bg-cream: #fdfaf1;        /* same as --ast-global-color-5 on the site:contentReference[oaicite:1]{index=1} */
  --text-dark: #343f1e;       /* dark olive used for headings and body:contentReference[oaicite:2]{index=2} */
  --primary-green: #5c8607;   /* accent colour from the site:contentReference[oaicite:3]{index=3} */
  --secondary-green: #70a309; /* secondary accent colour:contentReference[oaicite:4]{index=4} */
}


/* Global typography */
body {
  background-color: var(--bg-cream);
  color: var(--text-dark);
  font-family: 'Inter', sans-serif;
  line-height: 1.7;
}
h1, h2, h3, h4, h5, h6 {
  font-family: 'Marcellus', serif;
  color: var(--text-dark);
  margin-top: 0;
  margin-bottom: 0.6em;
}
a {
  color: var(--primary-green);
}
a:hover {
  color: var(--secondary-green);
}


/* Override the research library hero and search container */
.hero {
  background: none;
  padding: 3rem 1rem;
}/* Align Ask AI and Search buttons vertically with search field on desktop */
@media (min-width: 600px) {
  .query-mode-toggle {
    display: flex;
    align-items: center;
     
  }   .query-mode-toggle .mode-btn {
    font-size: 1rem;
    padding-top: 0.6rem;
    padding-bottom: 0.6rem;
  }


}


.query-search-group {
  background-color: #ffffff;
  border-radius: 0.5rem;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
  padding: 1rem;
}
.search-wrapper input {
  background: var(--bg-cream);
  border: 1px solid #ccc;
  color: var(--text-dark);
  padding: 0.6rem 1rem;
  font-size: 1rem;
  border-radius: 30px;
}
.search-wrapper input::placeholder {
  color: rgba(52,63,30,0.6);
}
.mode-btn {
  background-color: var(--primary-green);
  color: #fff;
  border: none;
  padding: 0.6rem 1rem;
  border-radius: 30px;
  font-size: 0.9rem;
  cursor: pointer;
}
.mode-btn:not(.mode-btn--active) {
  background-color: var(--secondary-green);
}
.mode-btn--active {
  box-shadow: 0 0 0 2px var(--secondary-green) inset;
}
/* Distinct styles for Ask AI/Search buttons */
.query-mode-toggle .mode-btn {
  border: 1.5px solid var(--primary-green);
  background-color: transparent;      /* outline style for inactive state */
  color: var(--primary-green);
  padding: 7px 18px;
  border-radius: 30px;
  font-size: .85rem;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  transition: background-color .18s, color .18s, border-color .18s;
}
.query-mode-toggle .mode-btn--active {
  background-color: var(--primary-green); /* filled style for active state */
  color: #fff;
  border-color: var(--primary-green);
}
/* Optional: hover effects */
.query-mode-toggle .mode-btn:not(.mode-btn--active):hover {
  background-color: var(--primary-green);
  color: #fff;
}
.query-mode-toggle .mode-btn--active:hover {
  background-color: var(--primary-green);
  color: #fff;
}

/* Align the buttons with the search bar on desktop */
@media (min-width: 600px) {
  .query-mode-toggle {
    margin-bottom: 0;
    display: flex;
    align-items: center;
  }
}
/* Make hero subtitle and stats legible on cream background */
.hero-subtitle,
.hero-stats {
  color: var(--text);
}
