/* =========================================================
   Dark mode — applies when <html data-theme="dark"> is set.
   Scope: site frontend only (header, content, footer). Does NOT
   touch wp-admin or anything inside <iframe>.
   ========================================================= */

[data-theme="dark"] {
    --ti-text: #cbd5e1;
    --ti-ink: #f1f5f9;
    --ti-muted: #94a3b8;
    --ti-border: #1f2a3c;
    --ti-surface: #0f172a;
    --ti-surface-alt: #0b1220;
    color-scheme: dark;
}

/* Body & Astra base */
[data-theme="dark"] body,
[data-theme="dark"] .site,
[data-theme="dark"] #page {
    background: #0b1220;
    color: #cbd5e1;
}
[data-theme="dark"] .ast-container,
[data-theme="dark"] .site-content,
[data-theme="dark"] .ast-separate-container .ast-article-single,
[data-theme="dark"] .ast-separate-container #primary {
    background: transparent;
}

/* Headings + body text in single posts */
[data-theme="dark"] .entry-content,
[data-theme="dark"] .entry-content p,
[data-theme="dark"] .entry-content li,
[data-theme="dark"] .entry-content td,
[data-theme="dark"] .entry-content th {
    color: #cbd5e1;
}
[data-theme="dark"] .entry-title,
[data-theme="dark"] .entry-content h1,
[data-theme="dark"] .entry-content h2,
[data-theme="dark"] .entry-content h3,
[data-theme="dark"] .entry-content h4,
[data-theme="dark"] .entry-content h5,
[data-theme="dark"] .entry-content h6 {
    color: #f1f5f9 !important;
}
[data-theme="dark"] .entry-content a {
    color: #4fc3f7;
}
[data-theme="dark"] .entry-content a:hover { color: #7dd3fc; }
[data-theme="dark"] .entry-content blockquote {
    background: #0f172a;
    border-left: 3px solid #4fc3f7;
    color: #cbd5e1;
}
[data-theme="dark"] .entry-content code {
    background: #1e293b;
    color: #e0f2fe;
    border-color: #334155;
}
[data-theme="dark"] .entry-content pre {
    background: #0f172a;
    color: #e0f2fe;
    border: 1px solid #1e293b;
}
[data-theme="dark"] .entry-content pre code {
    background: transparent; border: 0;
}
[data-theme="dark"] .entry-content table th,
[data-theme="dark"] .entry-content table td {
    border-color: #1f2a3c;
}
[data-theme="dark"] .entry-content table th {
    background: #0f172a;
    color: #f1f5f9;
}

/* Reading-time badge / TOC / Up Next */
[data-theme="dark"] .ti-post-meta-bar .ti-read-time-badge {
    background: #0f172a;
    color: #94a3b8;
    border-color: #1f2a3c;
}
[data-theme="dark"] .ti-toc {
    background: #0f172a;
    border-color: #1f2a3c;
}
[data-theme="dark"] .ti-toc-title { color: #f1f5f9; }
[data-theme="dark"] .ti-toc-list a { color: #cbd5e1; }
[data-theme="dark"] .ti-toc-list a:hover { color: #4fc3f7; }
[data-theme="dark"] .ti-up-next {
    background: #0f172a;
    border-color: #1f2a3c;
}
[data-theme="dark"] .ti-up-next-heading { color: #f1f5f9; }
[data-theme="dark"] .ti-up-next-card {
    background: #0b1220;
    border-color: #1f2a3c;
}
[data-theme="dark"] .ti-up-next-card:hover { border-color: #4fc3f7; }
[data-theme="dark"] .ti-up-next-title { color: #e6edf6; }
[data-theme="dark"] .ti-up-next-meta { color: #94a3b8; }

/* Homepage — surface, cards, grid items, latest, company chips */
[data-theme="dark"] .ti-card {
    background: #0f172a;
    border-color: #1f2a3c;
}
[data-theme="dark"] .ti-card h2,
[data-theme="dark"] .ti-card h3 { color: #f1f5f9; }
[data-theme="dark"] .ti-card p { color: #94a3b8; }
[data-theme="dark"] .ti-card-icon {
    background: linear-gradient(135deg, rgba(41,128,185,0.18), rgba(46,204,113,0.10));
    border-color: #1f2a3c;
}
[data-theme="dark"] .ti-card-count {
    background: #0b1220; border-color: #1f2a3c;
}
[data-theme="dark"] .ti-card-pills span {
    background: #0b1220; border-color: #1f2a3c; color: #94a3b8;
}
[data-theme="dark"] .ti-grid-item {
    background: #0f172a; border-color: #1f2a3c; color: #cbd5e1;
}
[data-theme="dark"] a.ti-grid-item:hover {
    background: rgba(79,195,247,0.07); border-color: #4fc3f7; color: #4fc3f7;
}
[data-theme="dark"] span.ti-grid-item { opacity: 0.4; }
[data-theme="dark"] .ti-company-chip {
    background: #0f172a; border-color: #1f2a3c;
}
[data-theme="dark"] .ti-company-chip:hover {
    background: #0f172a; border-color: #4fc3f7;
}
[data-theme="dark"] .ti-chip-name { color: #e6edf6; }
[data-theme="dark"] .ti-company-chip:hover .ti-chip-name { color: #4fc3f7; }
[data-theme="dark"] .ti-latest-item {
    background: #0f172a; border-color: #1f2a3c;
}
[data-theme="dark"] .ti-latest-item:hover { background: #111b30; border-color: #4fc3f7; }
[data-theme="dark"] .ti-latest-title { color: #e6edf6; }
[data-theme="dark"] .ti-latest-date {
    background: #0b1220; color: #94a3b8;
}
[data-theme="dark"] .ti-section h2 { color: #f1f5f9; }
[data-theme="dark"] .ti-section-sub { color: #94a3b8; }
[data-theme="dark"] .ti-section:nth-child(even) { background: #0f172a; }

/* Section corner ornaments — slightly more visible on dark */
[data-theme="dark"] .ti-section:not(.ti-hero):nth-child(odd)::before,
[data-theme="dark"] .ti-section:not(.ti-hero):nth-child(odd)::after {
    color: rgba(79, 195, 247, 0.06);
}

/* Archive cards (article excerpts) */
[data-theme="dark"] .entry-header,
[data-theme="dark"] .entry-meta,
[data-theme="dark"] .ast-archive-description,
[data-theme="dark"] .ti-card-cta { color: #94a3b8; }
[data-theme="dark"] .ti-card-cta { color: #4fc3f7; }
[data-theme="dark"] .ti-read-time { color: #94a3b8; }
[data-theme="dark"] .ast-article-post {
    background: #0f172a;
    border: 1px solid #1f2a3c;
    border-radius: 10px;
}

/* Pagination */
[data-theme="dark"] .ast-pagination .page-numbers {
    background: #0f172a; color: #cbd5e1; border-color: #1f2a3c;
}
[data-theme="dark"] .ast-pagination .page-numbers.current,
[data-theme="dark"] .ast-pagination .page-numbers:hover {
    background: #2980b9; color: #fff; border-color: #2980b9;
}

/* Search/results & generic Astra titles */
[data-theme="dark"] .page-title,
[data-theme="dark"] .ast-archive-title {
    color: #f1f5f9 !important;
}

/* Header dark-mode toggle button states */
.ti-theme-toggle {
    background: transparent; border: 0; color: var(--ti-h-text);
    width: 36px; height: 36px;
    display: inline-flex; align-items: center; justify-content: center;
    cursor: pointer; flex-shrink: 0;
    border-radius: 8px;
    transition: background 0.15s ease, color 0.15s ease;
}
.ti-theme-toggle:hover { background: rgba(255,255,255,0.06); color: #fff; }
.ti-theme-toggle .ti-icon-sun,
.ti-theme-toggle .ti-icon-moon,
.ti-theme-toggle .ti-icon-auto { display: none; }
[data-theme="light"] .ti-theme-toggle .ti-icon-sun { display: inline-block; }
[data-theme="dark"] .ti-theme-toggle .ti-icon-moon { display: inline-block; }
.ti-theme-toggle[data-mode="auto"] .ti-icon-auto { display: inline-block; }
/* Default (no data-theme attr): show auto icon */
:root:not([data-theme]) .ti-theme-toggle .ti-icon-auto,
:root[data-theme=""] .ti-theme-toggle .ti-icon-auto { display: inline-block; }

@media (max-width: 1023px) {
    .ti-theme-toggle { display: none; } /* mobile users use system pref + drawer */
}
