/* ═══════════════════════════════════════════════════════════
   BioMedica Insights — Main Stylesheet
   ═══════════════════════════════════════════════════════════ */

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

:root {
    --navy:       #0d1b2a;
    --navy-mid:   #1a3050;
    --blue:       #1d6fa4;
    --blue-light: #2e8ec7;
    --teal:       #00897b;
    --teal-light: #00acc1;
    --red:        #c0392b;
    --amber:      #d4830a;
    --purple:     #6d35a0;
    --green:      #27704e;

    --bg:         #f5f6f8;
    --surface:    #ffffff;
    --border:     #dde2e8;
    --border-dark:#b8c0cc;

    --text:       #1a1f2e;
    --text-mid:   #3d4555;
    --text-light: #6b7585;

    --font-serif: 'Playfair Display', Georgia, 'Times New Roman', serif;
    --font-sans:  'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;

    --radius:     6px;
    --radius-lg:  12px;
    --shadow-sm:  0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.06);
    --shadow:     0 4px 16px rgba(0,0,0,.10), 0 1px 4px rgba(0,0,0,.06);
    --shadow-lg:  0 12px 40px rgba(0,0,0,.14), 0 4px 12px rgba(0,0,0,.08);

    --max-w:      1200px;
    --gutter:     24px;
}

html { scroll-behavior: smooth; font-size: 16px; }

body {
    font-family: var(--font-sans);
    background: var(--bg);
    color: var(--text);
    line-height: 1.65;
    -webkit-font-smoothing: antialiased;
}

img { display: block; width: 100%; height: auto; object-fit: cover; }
a   { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
ul  { list-style: none; }

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

/* ── Category Badges ──────────────────────────────────────── */
.cat-badge {
    display: inline-block;
    font-family: var(--font-sans);
    font-size: .68rem;
    font-weight: 600;
    letter-spacing: .07em;
    text-transform: uppercase;
    padding: 3px 9px;
    border-radius: 3px;
    margin-bottom: 10px;
    color: #fff;
}
.cat-genomics { background: var(--blue); }
.cat-neuro    { background: var(--purple); }
.cat-oncology { background: var(--red); }
.cat-pharma   { background: var(--teal); }
.cat-aging    { background: var(--green); }
.cat-imaging  { background: var(--amber); }

/* ── Article Meta ─────────────────────────────────────────── */
.article-meta {
    font-size: .82rem;
    color: var(--text-light);
    margin-top: 12px;
}
.author      { font-weight: 500; color: var(--text-mid); }
.meta-sep    { margin: 0 6px; }
.read-time   {}

/* ═══════════════════════════════════════════════════════════
   HEADER
   ═══════════════════════════════════════════════════════════ */
.site-header {
    background: var(--navy);
    border-bottom: 3px solid var(--blue-light);
}

.header-top-bar {
    background: var(--navy-mid);
    padding: 6px 0;
    font-size: .78rem;
    color: rgba(255,255,255,.55);
}
.header-top-bar .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.header-main-bar {
    padding: 24px 0 20px;
    text-align: center;
    border-bottom: 1px solid rgba(255,255,255,.1);
}
.site-title {
    font-family: var(--font-serif);
    font-size: clamp(2rem, 5vw, 3.5rem);
    font-weight: 900;
    color: #fff;
    letter-spacing: -.02em;
    line-height: 1;
}
.site-title span { color: var(--teal-light); }
.site-subtitle {
    font-size: .85rem;
    color: rgba(255,255,255,.5);
    letter-spacing: .1em;
    text-transform: uppercase;
    margin-top: 6px;
}

/* Nav */
.header-nav { padding: 0; }
.nav-list {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 0;
}
.nav-list li a {
    display: block;
    padding: 12px 16px;
    font-size: .82rem;
    font-weight: 500;
    color: rgba(255,255,255,.75);
    text-transform: uppercase;
    letter-spacing: .06em;
    transition: color .2s, background .2s;
}
.nav-list li a:hover {
    color: #fff;
    background: rgba(255,255,255,.08);
    text-decoration: none;
}

/* ═══════════════════════════════════════════════════════════
   HERO SECTION
   ═══════════════════════════════════════════════════════════ */
.hero-section {
    background: var(--surface);
    padding: 48px 0 36px;
    border-bottom: 1px solid var(--border);
}

.hero-grid {
    display: grid;
    grid-template-columns: 1fr 440px;
    gap: 48px;
    align-items: start;
}

.hero-main-article .hero-title {
    font-family: var(--font-serif);
    font-size: clamp(1.7rem, 3vw, 2.6rem);
    font-weight: 700;
    line-height: 1.2;
    color: var(--navy);
    margin: 6px 0 16px;
}

.hero-excerpt {
    font-size: 1.05rem;
    line-height: 1.7;
    color: var(--text-mid);
}

/* Hero right column */
.hero-image-col { display: flex; flex-direction: column; gap: 24px; }

.hero-figure { border-radius: var(--radius-lg); overflow: hidden; }
.hero-figure img { height: 280px; }
.hero-figure figcaption {
    font-size: .75rem;
    color: var(--text-light);
    padding: 8px 0 0;
    font-style: italic;
}

/* Sidebar mini-article */
.sidebar-article {
    background: var(--bg);
    border-left: 4px solid var(--purple);
    padding: 16px 20px;
    border-radius: 0 var(--radius) var(--radius) 0;
}
.sidebar-article h4 {
    font-family: var(--font-serif);
    font-size: 1rem;
    line-height: 1.4;
    margin: 6px 0 8px;
    color: var(--navy);
}
.sidebar-article h4 a { color: var(--navy); }
.sidebar-article h4 a:hover { color: var(--blue); text-decoration: none; }
.sidebar-article p  { font-size: .85rem; color: var(--text-mid); }

/* ═══════════════════════════════════════════════════════════
   TICKER BAR
   ═══════════════════════════════════════════════════════════ */
.ticker-bar {
    background: var(--navy);
    padding: 10px 0;
    overflow: hidden;
}
.ticker-inner {
    display: flex;
    align-items: center;
    gap: 16px;
}
.ticker-label {
    flex-shrink: 0;
    font-size: .7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .1em;
    color: #fff;
    background: var(--blue-light);
    padding: 4px 10px;
    border-radius: 3px;
}
.ticker-track {
    font-size: .82rem;
    color: rgba(255,255,255,.8);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.ticker-sep { color: rgba(255,255,255,.35); }

/* ═══════════════════════════════════════════════════════════
   ARTICLE GRID
   ═══════════════════════════════════════════════════════════ */
.articles-section {
    padding: 48px 0;
}
.section-label {
    font-size: .72rem;
    font-weight: 700;
    letter-spacing: .12em;
    text-transform: uppercase;
    color: var(--blue);
    border-bottom: 2px solid var(--blue);
    padding-bottom: 8px;
    margin-bottom: 28px;
}

.article-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 28px;
}

/* Wide card spans 2 cols */
.card-wide {
    grid-column: span 2;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0;
}
.card-wide .card-figure img { height: 100%; min-height: 220px; border-radius: var(--radius) 0 0 var(--radius); }
.card-wide .card-body { padding: 24px 24px 24px 28px; }

/* Article card */
.article-card {
    background: var(--surface);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    transition: box-shadow .25s, transform .25s;
}
.article-card:hover {
    box-shadow: var(--shadow);
    transform: translateY(-3px);
}

.card-figure img { height: 190px; }

.card-body { padding: 20px; }
.card-body h3 {
    font-family: var(--font-serif);
    font-size: 1.05rem;
    line-height: 1.35;
    margin: 6px 0 10px;
    color: var(--navy);
}
.card-body h3 a { color: var(--navy); }
.card-body h3 a:hover { color: var(--blue); text-decoration: none; }
.card-body p { font-size: .875rem; color: var(--text-mid); line-height: 1.6; }

/* ═══════════════════════════════════════════════════════════
   AI RESPONSE SECTION
   ═══════════════════════════════════════════════════════════ */
.ai-response-section {
    background: linear-gradient(180deg, #eef4fb 0%, #f5f6f8 100%);
    padding: 52px 0 64px;
    border-top: 3px solid var(--blue-light);
}

.ai-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 32px;
}
.ai-section-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: .78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .1em;
    color: var(--blue);
    border-bottom: 2px solid var(--blue);
    padding-bottom: 8px;
}
.ai-close-btn {
    background: none;
    border: 1px solid var(--border-dark);
    color: var(--text-light);
    width: 32px; height: 32px;
    border-radius: 50%;
    cursor: pointer;
    font-size: .9rem;
    display: flex; align-items: center; justify-content: center;
    transition: background .2s, color .2s;
}
.ai-close-btn:hover { background: var(--navy); color: #fff; border-color: var(--navy); }

/* ── AI Article Content (styled to match magazine) ────────── */
.ai-content-area {
    background: var(--surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
}

/* All elements inside the AI article */
.ai-content-area .ai-article {
    padding: 48px 56px 56px;
    max-width: 860px;
    margin: 0 auto;
}

.ai-content-area .article-title {
    font-family: var(--font-serif);
    font-size: clamp(1.8rem, 3.5vw, 2.8rem);
    font-weight: 700;
    line-height: 1.15;
    color: var(--navy);
    margin-bottom: 20px;
    border-bottom: 3px solid var(--blue-light);
    padding-bottom: 20px;
}

.ai-content-area .article-lead {
    font-size: 1.18rem;
    line-height: 1.75;
    color: var(--text-mid);
    font-weight: 400;
    margin-bottom: 32px;
    padding-bottom: 24px;
    border-bottom: 1px solid var(--border);
}

.ai-content-area h3 {
    font-family: var(--font-serif);
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--navy);
    margin: 36px 0 14px;
    padding-left: 14px;
    border-left: 4px solid var(--blue-light);
}

.ai-content-area p {
    font-size: .975rem;
    line-height: 1.8;
    color: var(--text);
    margin-bottom: 18px;
}

.ai-content-area ul,
.ai-content-area ol {
    margin: 0 0 20px 20px;
    list-style: disc;
}
.ai-content-area ol { list-style: decimal; }
.ai-content-area li {
    font-size: .975rem;
    line-height: 1.75;
    color: var(--text);
    margin-bottom: 6px;
}

/* Pull quote */
.ai-content-area .highlight-quote {
    margin: 32px 0;
    padding: 24px 32px;
    background: linear-gradient(135deg, #e8f4fb, #eef7ff);
    border-left: 5px solid var(--blue-light);
    border-radius: 0 var(--radius) var(--radius) 0;
    font-family: var(--font-serif);
    font-size: 1.2rem;
    font-style: italic;
    color: var(--navy-mid);
    line-height: 1.6;
}

/* Code / calculation blocks */
.ai-content-area .code-block {
    margin: 24px 0;
    background: #0d1b2a;
    border-radius: var(--radius);
    overflow-x: auto;
}
.ai-content-area .code-block pre {
    padding: 24px 28px;
}
.ai-content-area .code-block code {
    font-family: 'SFMono-Regular', 'Consolas', 'Liberation Mono', Menlo, monospace;
    font-size: .85rem;
    line-height: 1.7;
    color: #e2f0ff;
    white-space: pre;
}

/* Stat boxes */
.ai-content-area .stat-box {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    background: var(--navy);
    color: #fff;
    border-radius: var(--radius);
    padding: 18px 24px;
    margin: 8px 8px 8px 0;
    min-width: 120px;
}
.ai-content-area .stat-number {
    font-family: var(--font-serif);
    font-size: 2rem;
    font-weight: 900;
    color: var(--teal-light);
    line-height: 1;
}
.ai-content-area .stat-label {
    font-size: .75rem;
    text-transform: uppercase;
    letter-spacing: .07em;
    color: rgba(255,255,255,.7);
    margin-top: 6px;
    text-align: center;
}

/* Info box */
.ai-content-area .info-box {
    background: #fff8e1;
    border: 1px solid #ffe082;
    border-radius: var(--radius);
    padding: 18px 22px;
    margin: 24px 0;
    font-size: .9rem;
    color: var(--text);
    line-height: 1.7;
}
.ai-content-area .info-box strong { color: var(--amber); }

/* ═══════════════════════════════════════════════════════════
   QUERY FORM
   ═══════════════════════════════════════════════════════════ */
.query-section {
    background: var(--navy);
    padding: 64px 0;
}

.query-wrapper {
    max-width: 720px;
    margin: 0 auto;
}

.query-title {
    font-family: var(--font-serif);
    font-size: clamp(1.6rem, 3vw, 2.2rem);
    font-weight: 700;
    color: #fff;
    margin-bottom: 10px;
}

.query-subtitle {
    font-size: .95rem;
    color: rgba(255,255,255,.6);
    margin-bottom: 32px;
    line-height: 1.6;
}

.query-form {}

.form-label {
    display: block;
    font-size: .8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: rgba(255,255,255,.6);
    margin-bottom: 8px;
}

.form-textarea {
    width: 100%;
    background: rgba(255,255,255,.08);
    border: 1px solid rgba(255,255,255,.2);
    border-radius: var(--radius);
    color: #fff;
    font-family: var(--font-sans);
    font-size: .975rem;
    line-height: 1.65;
    padding: 16px 18px;
    resize: vertical;
    transition: border-color .2s, background .2s;
    outline: none;
}
.form-textarea::placeholder { color: rgba(255,255,255,.3); }
.form-textarea:focus {
    border-color: var(--teal-light);
    background: rgba(255,255,255,.12);
}

.char-counter {
    display: block;
    text-align: right;
    font-size: .75rem;
    color: rgba(255,255,255,.35);
    margin-top: 6px;
}

.form-actions { margin-top: 20px; }

.submit-btn {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    background: var(--teal);
    color: #fff;
    border: none;
    border-radius: var(--radius);
    padding: 14px 28px;
    font-family: var(--font-sans);
    font-size: .95rem;
    font-weight: 600;
    cursor: pointer;
    transition: background .2s, transform .15s;
}
.submit-btn:hover:not(:disabled) {
    background: var(--teal-light);
    transform: translateY(-1px);
}
.submit-btn:disabled { opacity: .5; cursor: not-allowed; }

/* Loading */
.loading-state {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 24px 0;
    color: rgba(255,255,255,.7);
    font-size: .95rem;
}
.spinner {
    width: 28px; height: 28px;
    border: 3px solid rgba(255,255,255,.2);
    border-top-color: var(--teal-light);
    border-radius: 50%;
    animation: spin .8s linear infinite;
    flex-shrink: 0;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Error */
.error-state {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    background: rgba(192,57,43,.2);
    border: 1px solid rgba(192,57,43,.4);
    border-radius: var(--radius);
    padding: 14px 18px;
    color: #ff8a80;
    font-size: .9rem;
    margin-top: 16px;
}
.error-state svg { flex-shrink: 0; margin-top: 1px; }

/* ═══════════════════════════════════════════════════════════
   HISTORY
   ═══════════════════════════════════════════════════════════ */
.history-section {
    background: var(--navy-mid);
    padding: 32px 0 40px;
}

.history-title {
    font-family: var(--font-sans);
    font-size: .72rem;
    font-weight: 700;
    letter-spacing: .12em;
    text-transform: uppercase;
    color: rgba(255,255,255,.4);
    margin-bottom: 16px;
}

.history-links {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: flex-start;
}

.history-link {
    display: inline-block;
    background: rgba(255,255,255,.07);
    color: rgba(255,255,255,.7);
    border: 1px solid rgba(255,255,255,.12);
    border-radius: 20px;
    padding: 5px 14px;
    font-size: .8rem;
    transition: background .2s, color .2s, border-color .2s;
    cursor: pointer;
    max-width: 280px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.history-link:hover {
    background: rgba(255,255,255,.15);
    color: #fff;
    border-color: rgba(255,255,255,.3);
    text-decoration: none;
}
.history-link.active {
    background: var(--teal);
    color: #fff;
    border-color: var(--teal);
}

.no-history {
    font-size: .85rem;
    color: rgba(255,255,255,.3);
    font-style: italic;
}

/* ═══════════════════════════════════════════════════════════
   FOOTER
   ═══════════════════════════════════════════════════════════ */
.site-footer {
    background: #070f1a;
    padding: 48px 0 0;
    color: rgba(255,255,255,.55);
    font-size: .875rem;
}

.footer-grid {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr;
    gap: 48px;
    padding-bottom: 40px;
    border-bottom: 1px solid rgba(255,255,255,.08);
}

.footer-logo {
    font-family: var(--font-serif);
    font-size: 1.5rem;
    font-weight: 700;
    color: #fff;
    margin-bottom: 12px;
}
.footer-logo span { color: var(--teal-light); }
.footer-brand p { line-height: 1.7; }

.footer-col h4 {
    font-size: .8rem;
    font-weight: 700;
    letter-spacing: .1em;
    text-transform: uppercase;
    color: rgba(255,255,255,.4);
    margin-bottom: 14px;
}
.footer-col ul li { margin-bottom: 8px; }
.footer-col ul li a {
    color: rgba(255,255,255,.55);
    transition: color .2s;
}
.footer-col ul li a:hover { color: #fff; text-decoration: none; }

.footer-bottom {
    padding: 20px 0;
    text-align: center;
    font-size: .78rem;
    color: rgba(255,255,255,.25);
}

/* ═══════════════════════════════════════════════════════════
   RESPONSIVE
   ═══════════════════════════════════════════════════════════ */
@media (max-width: 900px) {
    .hero-grid { grid-template-columns: 1fr; }
    .hero-image-col { display: none; }

    .article-grid { grid-template-columns: 1fr 1fr; }
    .card-wide {
        grid-column: span 2;
        grid-template-columns: 1fr;
    }
    .card-wide .card-figure img { height: 220px; border-radius: var(--radius) var(--radius) 0 0; }
    .card-wide .card-body { padding: 20px; }

    .footer-grid { grid-template-columns: 1fr 1fr; }
    .footer-brand { grid-column: span 2; }

    .ai-content-area .ai-article { padding: 32px 28px 40px; }
}

@media (max-width: 600px) {
    :root { --gutter: 16px; }

    .header-top-bar .container { flex-direction: column; gap: 2px; text-align: center; }
    .nav-list li a { padding: 10px 10px; font-size: .75rem; }

    .article-grid { grid-template-columns: 1fr; }
    .card-wide { grid-column: span 1; }

    .footer-grid { grid-template-columns: 1fr; }
    .footer-brand { grid-column: span 1; }

    .ai-content-area .ai-article { padding: 24px 18px 32px; }
    .ai-content-area .article-title { font-size: 1.5rem; }
    .ai-content-area .highlight-quote { padding: 16px 20px; font-size: 1rem; }

    .query-section { padding: 48px 0; }
}
