/*
 * Nutriofia Environmental Chemicals Database
 * External Stylesheet — chemicals.css
 *
 * Covers all shared styles for the chemicals section:
 *   chemical.php  (profile pages)
 *   index.php     (chemicals listing)
 *   category.php  (category pages)
 *   family.php    (family pages)
 *
 * Include via head_includes.php — do not duplicate these rules inline.
 * Page-specific overrides can still be added in a <style> block on that page.
 *
 * Colour palette (CSS custom properties — change once, updates everywhere):
 *   --navy   #1B3A6B   headings, breadcrumbs, primary text
 *   --teal   #0D7377   accents, badges, links, highlights
 *   --amber  #E8A020   preclinical evidence badge, warnings
 *   --light  #f4f8f8   backgrounds, search bar
 *   --border #d8e4e4   card borders, dividers
 *   --text   #2d2d2d   body copy
 */

/* ═══════════════════════════════════════════════════════════════════════════
   CSS CUSTOM PROPERTIES (design tokens)
   ═══════════════════════════════════════════════════════════════════════════ */
:root {
    --navy:   #1B3A6B;
    --teal:   #0D7377;
    --amber:  #E8A020;
    --light:  #f4f8f8;
    --border: #d8e4e4;
    --text:   #2d2d2d;
}


/* ═══════════════════════════════════════════════════════════════════════════
   LAYOUT
   ═══════════════════════════════════════════════════════════════════════════ */
.chem-content {
    max-width: 860px;
    margin: 0 auto;
    padding: 0 20px;
}


/* ═══════════════════════════════════════════════════════════════════════════
   HERO BANNER
   ═══════════════════════════════════════════════════════════════════════════ */
.chem-hero {
    background: linear-gradient(135deg, var(--navy) 0%, #2a5298 100%);
    color: #fff;
    padding: 40px 0 32px;
}
.chem-hero h1 {
    font-size: 2rem;
    font-weight: 700;
    margin: 0 0 8px;
}
.chem-hero .iupac {
    font-size: 0.85rem;
    opacity: 0.75;
    font-style: italic;
    margin-bottom: 12px;
}
.chem-hero .cas {
    font-size: 0.8rem;
    opacity: 0.65;
}
.chem-hero .family-pill {
    display: inline-block;
    background: var(--teal);
    color: #fff;
    font-size: 0.78rem;
    padding: 3px 12px;
    border-radius: 20px;
    margin-top: 10px;
    text-decoration: none;
}
.chem-hero .family-pill:hover {
    background: #0a5f63;
}


/* ═══════════════════════════════════════════════════════════════════════════
   BREADCRUMB
   ═══════════════════════════════════════════════════════════════════════════ */
.breadcrumb {
    font-size: 0.82rem;
    color: rgba(255,255,255,0.7);
    margin-bottom: 14px;
}
.breadcrumb a {
    color: rgba(255,255,255,0.85);
    text-decoration: none;
}
.breadcrumb a:hover {
    text-decoration: underline;
}
.breadcrumb span {
    margin: 0 6px;
}


/* ═══════════════════════════════════════════════════════════════════════════
   SEARCH BAR (back bar above hero)
   ═══════════════════════════════════════════════════════════════════════════ */
.chem-searchbar {
    background: var(--light);
    border-bottom: 1px solid var(--border);
    padding: 12px 0;
}
.chem-searchbar .chem-content {
    display: flex;
    align-items: center;
    gap: 14px;
}
.chem-searchbar input {
    flex: 1;
    max-width: 460px;
    padding: 8px 14px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 0.9rem;
    font-family: inherit;
    color: var(--text);
    background: #fff;
}
.chem-searchbar input:focus {
    outline: none;
    border-color: var(--teal);
    box-shadow: 0 0 0 3px rgba(13,115,119,0.15);
}
.back-link {
    font-size: 0.85rem;
    color: var(--navy);
    text-decoration: none;
    white-space: nowrap;
}
.back-link:hover {
    color: var(--teal);
}


/* ═══════════════════════════════════════════════════════════════════════════
   SUMMARY BLOCK
   ═══════════════════════════════════════════════════════════════════════════ */
.chem-summary {
    font-size: 1.05rem;
    color: var(--text);
    line-height: 1.7;
    border-left: 4px solid var(--teal);
    padding-left: 16px;
    margin: 24px 0 30px;
}


/* ═══════════════════════════════════════════════════════════════════════════
   CATEGORY TAGS
   ═══════════════════════════════════════════════════════════════════════════ */
.cat-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 0;
    padding: 0;
    list-style: none;
}
.cat-tag {
    background: var(--light);
    border: 1px solid var(--border);
    color: var(--navy);
    font-size: 0.8rem;
    padding: 4px 12px;
    border-radius: 20px;
    text-decoration: none;
    transition: background 0.15s, border-color 0.15s;
}
.cat-tag:hover {
    background: #e0eded;
    border-color: var(--teal);
}


/* ═══════════════════════════════════════════════════════════════════════════
   INFO CARD GRID
   ═══════════════════════════════════════════════════════════════════════════ */
.chem-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin: 30px 0;
}
.info-card {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 20px 22px;
}
.info-card.full-width {
    grid-column: 1 / -1;
}
.info-card h2 {
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--teal);
    margin: 0 0 10px;
}
.info-card p {
    font-size: 0.93rem;
    color: var(--text);
    line-height: 1.65;
    margin: 0 0 8px;
}
.info-card p:last-child {
    margin-bottom: 0;
}


/* ═══════════════════════════════════════════════════════════════════════════
   NUTRIOFIA PERSPECTIVE CARD
   ═══════════════════════════════════════════════════════════════════════════ */
.card-nutriofia {
    background: linear-gradient(135deg, #f0f7f7 0%, #e6f4f1 100%);
    border-color: var(--teal);
}
.card-nutriofia h2 {
    color: var(--navy);
}
.card-nutriofia .nutriofia-logo-text {
    font-size: 0.72rem;
    color: var(--teal);
    font-weight: 600;
    margin-bottom: 8px;
    display: block;
    letter-spacing: 0.08em;
}


/* ═══════════════════════════════════════════════════════════════════════════
   EVIDENCE BADGE
   ═══════════════════════════════════════════════════════════════════════════ */
.ev-badge {
    display: inline-block;
    padding: 3px 11px;
    border-radius: 20px;
    font-size: 0.78rem;
    font-weight: 600;
    letter-spacing: 0.03em;
    vertical-align: middle;
}
.evidence-row {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 12px;
}
.evidence-row .ev-badge {
    flex-shrink: 0;
}


/* ═══════════════════════════════════════════════════════════════════════════
   REGULATORY STATUS TAG
   ═══════════════════════════════════════════════════════════════════════════ */
.reg-status {
    display: inline-block;
    background: #fff3cd;
    color: #856404;
    border: 1px solid #ffc107;
    border-radius: 4px;
    font-size: 0.8rem;
    padding: 2px 8px;
    margin-bottom: 8px;
}


/* ═══════════════════════════════════════════════════════════════════════════
   SECTION SEPARATOR
   ═══════════════════════════════════════════════════════════════════════════ */
.section-sep {
    border: none;
    border-top: 1px solid var(--border);
    margin: 28px 0;
}


/* ═══════════════════════════════════════════════════════════════════════════
   TOOLTIPS  (populated by tooltips.js)
   ═══════════════════════════════════════════════════════════════════════════ */

/* The trigger — any element with data-tip gets this treatment */
[data-tip] {
    border-bottom: 1px dotted var(--teal);
    cursor: help;
    color: inherit;
    position: relative;
}

/* The tooltip bubble — created dynamically by tooltips.js */
.nutriofia-tooltip {
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    z-index: 10000;
    background: var(--navy);
    color: #fff;
    font-size: 0.8rem;
    line-height: 1.5;
    padding: 8px 12px;
    border-radius: 6px;
    width: max-content;
    max-width: 280px;
    white-space: normal;
    box-shadow: 0 4px 12px rgba(0,0,0,0.25);
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.15s ease;
}

/* Arrow pointing down from bubble */
.nutriofia-tooltip::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 6px solid transparent;
    border-top-color: var(--navy);
}

/* Visible state — toggled by tooltips.js */
.nutriofia-tooltip.visible {
    opacity: 1;
}

/* If tooltip would go off left edge of screen */
.nutriofia-tooltip.tip-left {
    left: 0;
    transform: none;
}
.nutriofia-tooltip.tip-left::after {
    left: 20px;
    transform: none;
}

/* If tooltip would go off right edge of screen */
.nutriofia-tooltip.tip-right {
    left: auto;
    right: 0;
    transform: none;
}
.nutriofia-tooltip.tip-right::after {
    left: auto;
    right: 20px;
    transform: none;
}


/* ═══════════════════════════════════════════════════════════════════════════
   AUTOCOMPLETE DROPDOWN  (also in chemical_autocomplete.js but centralised here)
   ═══════════════════════════════════════════════════════════════════════════ */
.chem-autocomplete-dropdown {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    z-index: 9999;
    margin: 0;
    padding: 0;
    list-style: none;
    background: #ffffff;
    border: 1px solid var(--border);
    border-top: none;
    border-radius: 0 0 6px 6px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.12);
    max-height: 340px;
    overflow-y: auto;
    font-family: inherit;
}
.chem-ac-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 14px;
    cursor: pointer;
    border-bottom: 1px solid #f0f0f0;
    transition: background 0.1s;
}
.chem-ac-item:last-child { border-bottom: none; }
.chem-ac-item:hover,
.chem-ac-item.chem-ac-active {
    background: #f0f7f7;
}
.chem-ac-name {
    font-size: 0.95rem;
    color: var(--navy);
    flex: 1;
}
.chem-ac-name strong {
    color: var(--teal);
    font-weight: 700;
}
.chem-ac-family {
    font-size: 0.75rem;
    color: #ffffff;
    background: var(--teal);
    padding: 2px 8px;
    border-radius: 20px;
    margin-left: 10px;
    white-space: nowrap;
    flex-shrink: 0;
}
.chem-ac-empty,
.chem-ac-error {
    padding: 12px 14px;
    font-size: 0.9rem;
    color: #666;
    text-align: center;
}
.chem-ac-error { color: #c0392b; }


/* ═══════════════════════════════════════════════════════════════════════════
   RESPONSIVE
   ═══════════════════════════════════════════════════════════════════════════ */
/* ═══════════════════════════════════════════════════════════════════════════
   CATEGORY INDEX PAGE  (categories.php — /chemicals/)
   ═══════════════════════════════════════════════════════════════════════════ */

.hero-standfirst {
    font-size: 1.1rem;
    color: rgba(255,255,255,0.9);
    max-width: 680px;
    margin: 0.75rem 0 1.25rem;
    line-height: 1.65;
}

/* Inline search on the index hero */
.chem-searchbar-inline {
    max-width: 520px;
    margin-top: 0.5rem;
}
.chem-searchbar-inline .chem-search-input {
    width: 100%;
}

.section-heading {
    font-size: 1.4rem;
    color: var(--navy);
    margin: 2rem 0 1.25rem;
    font-weight: 700;
}

/* ── Category card grid ──────────────────────────────────────────────────── */
.cat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 2.5rem;
}

.cat-card {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.35rem;
    background: #fff;
    border: 1.5px solid var(--border);
    border-radius: 10px;
    padding: 1.1rem 1.1rem 1rem;
    text-decoration: none;
    color: var(--text);
    transition: border-color 0.18s, box-shadow 0.18s, transform 0.15s;
}

.cat-card:hover,
.cat-card:focus {
    border-color: var(--teal);
    box-shadow: 0 4px 16px rgba(13,115,119,0.13);
    transform: translateY(-2px);
    outline: none;
}

.cat-icon {
    font-size: 1.9rem;
    line-height: 1;
    margin-bottom: 0.2rem;
}

.cat-name {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--navy);
    line-height: 1.3;
}

.cat-desc {
    font-size: 0.8rem;
    color: #555;
    line-height: 1.4;
    flex-grow: 1;
}

.cat-count {
    font-size: 0.78rem;
    color: var(--teal);
    font-weight: 600;
    margin-top: auto;
    padding-top: 0.4rem;
}

/* ── About section ───────────────────────────────────────────────────────── */
.about-section {
    background: var(--light);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 1.5rem 1.75rem;
    margin-top: 1rem;
}

.about-section h2 {
    font-size: 1.15rem;
    color: var(--navy);
    margin: 0 0 0.75rem;
}

.about-section p {
    font-size: 0.92rem;
    color: var(--text);
    line-height: 1.65;
    margin: 0 0 0.65rem;
}

.about-section p:last-child { margin-bottom: 0; }


/* ═══════════════════════════════════════════════════════════════════════════
   CATEGORY PAGE  (category.php — /chemicals/category/{slug}/)
   ═══════════════════════════════════════════════════════════════════════════ */

.chem-count-label {
    font-size: 0.9rem;
    color: rgba(255,255,255,0.75);
    margin: 0.4rem 0 0;
}

/* ── Chemical list cards ─────────────────────────────────────────────────── */
.chem-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin: 1.5rem 0 2rem;
}

.chem-list-card {
    display: block;
    background: #fff;
    border: 1.5px solid var(--border);
    border-radius: 10px;
    padding: 1.1rem 1.25rem;
    text-decoration: none;
    color: var(--text);
    transition: border-color 0.18s, box-shadow 0.18s;
}

.chem-list-card:hover,
.chem-list-card:focus {
    border-color: var(--teal);
    box-shadow: 0 3px 14px rgba(13,115,119,0.12);
    outline: none;
}

.clc-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 0.5rem;
    flex-wrap: wrap;
}

.clc-name {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--navy);
    margin: 0;
    line-height: 1.3;
}

.clc-meta {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-shrink: 0;
    flex-wrap: wrap;
}

.clc-family {
    font-size: 0.75rem;
    color: #666;
    background: var(--light);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 0.15rem 0.5rem;
    white-space: nowrap;
}

.clc-badge {
    font-size: 0.72rem;
    color: #fff;
    border-radius: 4px;
    padding: 0.18rem 0.55rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    white-space: nowrap;
}

.clc-teaser {
    font-size: 0.88rem;
    color: #555;
    line-height: 1.6;
    margin: 0 0 0.6rem;
}

.clc-link-label {
    font-size: 0.82rem;
    color: var(--teal);
    font-weight: 600;
}

.back-link {
    margin-top: 1.5rem;
    font-size: 0.9rem;
}

.back-link a {
    color: var(--teal);
    text-decoration: none;
    font-weight: 600;
}

.back-link a:hover { text-decoration: underline; }

/* Screenreader only */
.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;
}

/* ═══════════════════════════════════════════════════════════════════════════
   RESPONSIVE — small screens
   ═══════════════════════════════════════════════════════════════════════════ */
@media (max-width: 640px) {
    .chem-grid {
        grid-template-columns: 1fr;
    }
    .chem-hero h1 {
        font-size: 1.5rem;
    }
    .nutriofia-tooltip {
        max-width: 220px;
    }
}
