/*
Theme Name: BestAIToolix
Theme URI: https://bestaitoolix.com/blog/
Author: BestAIToolix
Description: Blog theme matching the BestAIToolix main site — neutral palette, Geist type, light and dark modes, no external requests.
Version: 1.0.0
Requires at least: 6.4
Requires PHP: 8.1
License: GPL-2.0-or-later
Text Domain: bestaitoolix
*/

/* ---------- Fonts (self-hosted Geist, OFL) ---------- */
@font-face {
  font-family: "Geist";
  src: url("assets/fonts/geist-latin.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Geist Mono";
  src: url("assets/fonts/geist-mono-latin.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

/* ---------- Tokens (Tailwind neutral scale, as on the main site) ---------- */
:root {
  --bg: #ffffff;
  --fg: #171717;
  --muted: #525252;      /* neutral-600 */
  --subtle: #737373;     /* neutral-500 */
  --line: #e5e5e5;       /* neutral-200 */
  --surface: #fafafa;    /* neutral-50 */
  --chip: #f5f5f5;       /* neutral-100 */
  --hover: #fafafa;
  --btn-bg: #171717;     /* neutral-900 */
  --btn-fg: #ffffff;
  --btn-hover: #404040;  /* neutral-700 */
  --code-bg: #f5f5f5;
  --pre-bg: #171717;
  --pre-fg: #e5e5e5;
  --header-bg: rgba(255, 255, 255, 0.9);
  --dot: #e5e5e5;
  --radius: 0.5rem;
  --max: 72rem;          /* max-w-6xl */
  --prose: 44rem;
  --sans: "Geist", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "Geist Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0a0a0a;
    --fg: #ededed;
    --muted: #a3a3a3;    /* neutral-400 */
    --subtle: #737373;
    --line: #262626;     /* neutral-800 */
    --surface: rgba(23, 23, 23, 0.4);
    --chip: #171717;
    --hover: #171717;
    --btn-bg: #f5f5f5;
    --btn-fg: #171717;
    --btn-hover: #d4d4d4;
    --code-bg: #171717;
    --pre-bg: #171717;
    --pre-fg: #e5e5e5;
    --header-bg: rgba(10, 10, 10, 0.9);
    --dot: #262626;
    color-scheme: dark;
  }
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--sans);
  font-size: 1rem;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
img, svg, video { max-width: 100%; height: auto; }
a { color: inherit; }
:focus-visible { outline: 2px solid var(--fg); outline-offset: 2px; border-radius: 2px; }
.btx-main { flex: 1; }
.btx-container { max-width: var(--max); margin: 0 auto; padding: 0 1.5rem; }
.screen-reader-text, .btx-sr {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}
.btx-skip {
  position: absolute; left: -9999px; top: 1rem; z-index: 60;
  background: var(--btn-bg); color: var(--btn-fg);
  padding: 0.5rem 0.75rem; border-radius: 0.375rem; text-decoration: none;
}
.btx-skip:focus { left: 1rem; }

/* ---------- Header (mirrors the main site's sticky header) ---------- */
.btx-header {
  position: sticky; top: 0; z-index: 40;
  border-bottom: 1px solid var(--line);
  background: var(--header-bg);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
}
.btx-header__inner {
  max-width: var(--max); margin: 0 auto; padding: 0 1.5rem;
  height: 3.5rem; display: flex; align-items: center; justify-content: space-between; gap: 1.5rem;
}
.btx-brand {
  font-size: 1.125rem; font-weight: 600; letter-spacing: -0.025em;
  text-decoration: none; white-space: nowrap;
}
.btx-brand span { color: var(--subtle); font-weight: 500; }
.btx-nav {
  display: flex; align-items: center; gap: 1.5rem;
  font-size: 0.875rem; font-weight: 500; color: var(--muted);
  overflow-x: auto; scrollbar-width: none; white-space: nowrap;
}
.btx-nav::-webkit-scrollbar { display: none; }
.btx-nav a { text-decoration: none; }
.btx-nav a:hover, .btx-nav a[aria-current="page"] { color: var(--fg); }
.btx-nav a[aria-current="page"] { text-decoration: underline; text-underline-offset: 6px; text-decoration-thickness: 2px; }
@media (max-width: 720px) {
  .btx-header__inner { gap: 1rem; }
  .btx-nav { gap: 1rem; mask-image: linear-gradient(to right, #000 85%, transparent); -webkit-mask-image: linear-gradient(to right, #000 85%, transparent); }
}

/* ---------- Buttons, chips ---------- */
.btx-btn {
  display: inline-flex; align-items: center; gap: 0.375rem;
  border-radius: 0.375rem; padding: 0.5rem 1rem;
  font-size: 0.875rem; font-weight: 500; text-decoration: none;
  background: var(--btn-bg); color: var(--btn-fg); border: 1px solid transparent;
}
.btx-btn:hover { background: var(--btn-hover); }
.btx-btn--ghost { background: transparent; color: var(--fg); border-color: var(--line); }
.btx-btn--ghost:hover { background: var(--hover); }
.btx-pill {
  display: inline-block; border: 1px solid var(--line); border-radius: 999px;
  padding: 0.25rem 0.75rem; font-size: 0.75rem; font-weight: 500; letter-spacing: 0.025em; color: var(--subtle);
}
.btx-chip {
  display: inline-block; border-radius: 999px; padding: 0.125rem 0.5rem;
  background: var(--chip); color: var(--muted); font-size: 0.75rem; text-decoration: none; white-space: nowrap;
}
a.btx-chip:hover { color: var(--fg); }
.btx-chips { display: flex; flex-wrap: wrap; gap: 0.5rem; justify-content: center; }
.btx-chips a { border: 1px solid var(--line); background: transparent; padding: 0.25rem 0.75rem; }
.btx-chips a:hover, .btx-chips a[aria-current="page"] { background: var(--chip); color: var(--fg); }

/* ---------- Hero ---------- */
.btx-hero { text-align: center; padding-top: 4.5rem; padding-bottom: 2rem; }
.btx-hero h1 {
  margin: 1.5rem auto 0; max-width: 48rem;
  font-size: clamp(2rem, 5vw, 3rem); line-height: 1.1; font-weight: 600; letter-spacing: -0.025em;
}
.btx-hero p.btx-lede { margin: 1rem auto 0; max-width: 42rem; font-size: 1.125rem; color: var(--muted); }
.btx-hero .btx-chips { margin-top: 2rem; }

/* ---------- Archive heading ---------- */
.btx-archive-head { padding-top: 3.5rem; padding-bottom: 1.5rem; }
.btx-archive-head .btx-kicker { margin: 0; }
.btx-archive-head h1 { margin: 0.5rem 0 0; font-size: 1.875rem; font-weight: 600; letter-spacing: -0.025em; }
.btx-archive-head p { margin: 0.5rem 0 0; color: var(--muted); max-width: 42rem; }
.btx-kicker { font-size: 0.75rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: var(--subtle); }
.btx-kicker a { text-decoration: none; }
.btx-kicker a:hover { color: var(--fg); }

/* ---------- Section heading ---------- */
.btx-section { padding-top: 2rem; padding-bottom: 3.5rem; }
.btx-section__head { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; margin-bottom: 1rem; }
.btx-section__head h2 { margin: 0; font-size: 1.125rem; font-weight: 600; }
.btx-section__head a { font-size: 0.875rem; color: var(--subtle); text-decoration: none; }
.btx-section__head a:hover { text-decoration: underline; }

/* ---------- Cover (typographic, used when a post has no featured image) ---------- */
.btx-cover {
  position: relative; overflow: hidden; border-radius: var(--radius);
  border: 1px solid var(--line); background-color: var(--surface);
  background-image: radial-gradient(var(--dot) 1px, transparent 1px);
  background-size: 16px 16px;
  aspect-ratio: 16 / 9; display: flex; flex-direction: column; justify-content: flex-end; padding: 1.25rem;
}
.btx-cover img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.btx-cover__label {
  position: relative; align-self: flex-start;
  font-size: clamp(1.125rem, 2.2vw, 1.5rem); font-weight: 600; letter-spacing: -0.02em; line-height: 1.2;
  color: var(--fg); background: var(--bg); border: 1px solid var(--line); border-radius: 0.375rem; padding: 0.25rem 0.625rem;
}
.btx-card .btx-cover__label { font-size: 1rem; }
/* Per-category pattern variants (monochrome, theme-aware) */
.btx-cover--grid { background-image: linear-gradient(var(--dot) 1px, transparent 1px), linear-gradient(90deg, var(--dot) 1px, transparent 1px); background-size: 24px 24px; }
.btx-cover--lines { background-image: repeating-linear-gradient(135deg, var(--dot) 0 1px, transparent 1px 12px); background-size: auto; }
.btx-cover--rings { background-image: radial-gradient(circle at 85% 30%, transparent 0 38px, var(--dot) 38px 39px, transparent 39px 62px, var(--dot) 62px 63px, transparent 63px 86px, var(--dot) 86px 87px, transparent 87px), radial-gradient(var(--dot) 1px, transparent 1px); background-size: auto, 16px 16px; }
.btx-cover__mark {
  position: absolute; top: 1rem; right: 1.25rem;
  font-family: var(--mono); font-size: 0.75rem; color: var(--subtle); letter-spacing: 0.02em;
}

/* ---------- Featured post ---------- */
.btx-featured {
  display: grid; gap: 2rem; align-items: center;
  border: 1px solid var(--line); border-radius: var(--radius); padding: 1.25rem;
  text-decoration: none; transition: background-color 0.15s;
}
.btx-featured:hover { background: var(--hover); }
.btx-featured h2 { margin: 0.5rem 0 0; font-size: clamp(1.5rem, 3vw, 2rem); line-height: 1.2; font-weight: 600; letter-spacing: -0.02em; }
.btx-featured p { margin: 0.75rem 0 0; color: var(--muted); }
@media (min-width: 860px) { .btx-featured { grid-template-columns: 1.1fr 1fr; padding: 1.5rem; } }

/* ---------- Card grid ---------- */
.btx-grid { display: grid; gap: 0.75rem; }
@media (min-width: 640px) { .btx-grid { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 1024px) { .btx-grid { grid-template-columns: repeat(3, 1fr); } }
.btx-card {
  display: flex; flex-direction: column; gap: 0.875rem;
  border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem;
  text-decoration: none; transition: background-color 0.15s;
}
.btx-card:hover { background: var(--hover); }
.btx-card h3 { margin: 0; font-size: 1rem; line-height: 1.4; font-weight: 600; }
.btx-card p { margin: 0; font-size: 0.875rem; color: var(--muted);
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.btx-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; font-size: 0.75rem; color: var(--subtle); }
.btx-meta .btx-dot::before { content: "·"; }
.btx-card .btx-meta { margin-top: auto; }

/* ---------- Empty state ---------- */
.btx-empty { border: 1px dashed var(--line); border-radius: var(--radius); padding: 3rem 1.5rem; text-align: center; color: var(--muted); }

/* ---------- Pagination ---------- */
.btx-pagination { margin-top: 2rem; }
.btx-pagination .nav-links { display: flex; flex-wrap: wrap; gap: 0.5rem; justify-content: center; }
.btx-pagination .page-numbers {
  min-width: 2.25rem; text-align: center; padding: 0.375rem 0.75rem;
  border: 1px solid var(--line); border-radius: 0.375rem; font-size: 0.875rem; text-decoration: none;
}
.btx-pagination .page-numbers.current { background: var(--btn-bg); color: var(--btn-fg); border-color: var(--btn-bg); }
.btx-pagination a.page-numbers:hover { background: var(--hover); }

/* ---------- Search form ---------- */
.btx-search { display: flex; gap: 0.5rem; max-width: 28rem; margin-top: 1.25rem; }
.btx-search input[type="search"] {
  flex: 1; min-width: 0; font: inherit; font-size: 0.875rem; color: var(--fg); background: var(--bg);
  border: 1px solid var(--line); border-radius: 0.375rem; padding: 0.5rem 0.75rem;
}
.btx-search input[type="search"]:focus { outline: 2px solid var(--fg); outline-offset: 0; }
.btx-search button { font: inherit; cursor: pointer; }

/* ---------- Single article ---------- */
.btx-article { padding-top: 3.5rem; padding-bottom: 1rem; }
.btx-article__head { max-width: var(--prose); margin: 0 auto; }
.btx-article__head h1 {
  margin: 0.75rem 0 0; font-size: clamp(1.875rem, 4.5vw, 2.75rem); line-height: 1.15;
  font-weight: 600; letter-spacing: -0.025em;
}
.btx-article__head .btx-dek { margin: 1rem 0 0; font-size: 1.125rem; color: var(--muted); }
.btx-article__head .btx-meta { margin-top: 1.25rem; font-size: 0.8125rem; }
.btx-article__cover { max-width: 56rem; margin: 2rem auto 0; }
.btx-backlink { display: inline-block; margin-bottom: 1.5rem; font-size: 0.875rem; color: var(--subtle); text-decoration: none; }
.btx-backlink:hover { color: var(--fg); }

/* ---------- Prose (post content) ---------- */
.btx-prose { max-width: var(--prose); margin: 2.5rem auto 0; font-size: 1.0625rem; line-height: 1.75; }
.btx-prose > * { margin-top: 0; margin-bottom: 1.25rem; }
.btx-prose h2 { margin-top: 2.5rem; margin-bottom: 0.75rem; font-size: 1.5rem; line-height: 1.3; font-weight: 600; letter-spacing: -0.015em; }
.btx-prose h3 { margin-top: 2rem; margin-bottom: 0.5rem; font-size: 1.1875rem; line-height: 1.4; font-weight: 600; }
.btx-prose h4 { margin-top: 1.5rem; margin-bottom: 0.5rem; font-size: 1rem; font-weight: 600; }
.btx-prose a { text-decoration: underline; text-underline-offset: 3px; text-decoration-color: var(--subtle); }
.btx-prose a:hover { text-decoration-color: var(--fg); }
.btx-prose strong { font-weight: 600; }
.btx-prose ul, .btx-prose ol { padding-left: 1.4rem; }
.btx-prose li { margin: 0.375rem 0; }
.btx-prose li::marker { color: var(--subtle); }
.btx-prose blockquote, .btx-prose .wp-block-quote {
  margin-left: 0; margin-right: 0; padding: 0.25rem 0 0.25rem 1.25rem;
  border-left: 3px solid var(--line); color: var(--muted);
}
.btx-prose blockquote cite { display: block; margin-top: 0.5rem; font-size: 0.875rem; font-style: normal; color: var(--subtle); }
.btx-prose code { font-family: var(--mono); font-size: 0.875em; background: var(--code-bg); padding: 0.125rem 0.375rem; border-radius: 0.25rem; }
.btx-prose pre { font-family: var(--mono); font-size: 0.875rem; line-height: 1.6; background: var(--pre-bg); color: var(--pre-fg); padding: 1rem 1.25rem; border-radius: var(--radius); overflow-x: auto; }
.btx-prose pre code { background: none; padding: 0; font-size: inherit; color: inherit; }
.btx-prose hr, .btx-prose .wp-block-separator { border: 0; border-top: 1px solid var(--line); margin: 2.5rem 0; }
.btx-prose img { border-radius: var(--radius); }
.btx-prose figure { margin-left: 0; margin-right: 0; }
.btx-prose figcaption, .btx-prose .wp-element-caption { margin-top: 0.5rem; font-size: 0.875rem; color: var(--subtle); text-align: center; }
.btx-prose table { width: 100%; border-collapse: collapse; font-size: 0.9375rem; }
.btx-prose .wp-block-table { overflow-x: auto; }
.btx-prose th, .btx-prose td { border-bottom: 1px solid var(--line); padding: 0.625rem 0.75rem; text-align: left; vertical-align: top; }
.btx-prose th { font-weight: 600; font-size: 0.8125rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--subtle); }
.btx-prose .wp-block-table table, .btx-prose .wp-block-table thead, .btx-prose .wp-block-table tfoot { border: 0; }
.btx-prose .wp-block-table th, .btx-prose .wp-block-table td { border: 0; border-bottom: 1px solid var(--line); }
.btx-prose .wp-block-table td:first-child { font-weight: 500; }
.btx-prose .alignwide { max-width: 56rem; margin-left: 50%; transform: translateX(-50%); width: min(56rem, calc(100vw - 3rem)); }
.btx-prose .alignfull { width: 100vw; max-width: 100vw; margin-left: 50%; transform: translateX(-50%); border-radius: 0; }
.btx-prose .alignleft { float: left; margin: 0.25rem 1.5rem 1rem 0; max-width: 50%; }
.btx-prose .alignright { float: right; margin: 0.25rem 0 1rem 1.5rem; max-width: 50%; }
.btx-prose .aligncenter { margin-left: auto; margin-right: auto; }
.btx-prose .wp-block-button__link { background: var(--btn-bg); color: var(--btn-fg); border-radius: 0.375rem; padding: 0.5rem 1rem; font-size: 0.875rem; text-decoration: none; }

/* Callout box (use the "Group" block with class name btx-callout) */
.btx-prose .btx-callout, .btx-callout {
  border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface);
  padding: 1rem 1.25rem; font-size: 0.9375rem;
}
.btx-callout > :first-child { margin-top: 0; }
.btx-callout > :last-child { margin-bottom: 0; }

/* ---------- Post footer: tags, CTA, prev/next ---------- */
.btx-post-foot { max-width: var(--prose); margin: 2.5rem auto 0; }
.btx-tags { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.btx-cta {
  margin-top: 2rem; border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--surface); padding: 1.5rem;
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 1rem;
}
.btx-cta h2 { margin: 0; font-size: 1rem; font-weight: 600; }
.btx-cta p { margin: 0.25rem 0 0; font-size: 0.875rem; color: var(--muted); }
.btx-postnav { margin-top: 2rem; display: grid; gap: 0.75rem; }
@media (min-width: 640px) { .btx-postnav { grid-template-columns: 1fr 1fr; } }
.btx-postnav a { display: block; border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem; text-decoration: none; }
.btx-postnav a:hover { background: var(--hover); }
.btx-postnav .btx-kicker { display: block; margin-bottom: 0.25rem; }
.btx-postnav .is-next { text-align: right; }
.btx-related { margin-top: 3.5rem; border-top: 1px solid var(--line); padding-top: 2.5rem; }

/* ---------- Comments (closed by default; styled for when enabled) ---------- */
.btx-comments { max-width: var(--prose); margin: 3rem auto 0; font-size: 0.9375rem; }
.btx-comments .comment-list { list-style: none; padding: 0; }
.btx-comments .comment-body { border-bottom: 1px solid var(--line); padding: 1rem 0; }
.btx-comments textarea, .btx-comments input[type="text"], .btx-comments input[type="email"], .btx-comments input[type="url"] {
  width: 100%; font: inherit; color: var(--fg); background: var(--bg); border: 1px solid var(--line); border-radius: 0.375rem; padding: 0.5rem 0.75rem;
}
.btx-comments .submit { font: inherit; cursor: pointer; background: var(--btn-bg); color: var(--btn-fg); border: 0; border-radius: 0.375rem; padding: 0.5rem 1rem; }

/* ---------- Newsletter-free "explore" band ---------- */
.btx-band { border-top: 1px solid var(--line); background: var(--surface); }
.btx-band__inner { padding-top: 3.5rem; padding-bottom: 3.5rem; display: grid; gap: 1.25rem; }
@media (min-width: 860px) { .btx-band__inner { grid-template-columns: repeat(3, 1fr); } }
.btx-band h2 { grid-column: 1 / -1; margin: 0; font-size: 1.125rem; font-weight: 600; }
.btx-band a { text-decoration: none; }
.btx-band h3 { margin: 0; font-size: 0.875rem; font-weight: 600; }
.btx-band p { margin: 0.375rem 0 0; font-size: 0.875rem; color: var(--muted); }
.btx-band a:hover h3 { text-decoration: underline; }

/* ---------- Footer (mirrors the main site's footer) ---------- */
.btx-footer { border-top: 1px solid var(--line); background: var(--bg); }
.btx-footer__inner { max-width: var(--max); margin: 0 auto; padding: 2rem 1.5rem; display: flex; flex-direction: column; gap: 0.5rem; font-size: 0.875rem; color: var(--subtle); }
.btx-footer p { margin: 0; }
.btx-footer .btx-small { font-size: 0.75rem; }
.btx-footer nav { margin-top: 0.5rem; display: flex; flex-wrap: wrap; gap: 0.25rem 1rem; font-size: 0.75rem; }
.btx-footer nav a { text-decoration: none; }
.btx-footer nav a:hover { text-decoration: underline; }

/* ---------- 404 ---------- */
.btx-404 { text-align: center; padding-top: 6rem; padding-bottom: 6rem; }
.btx-404 h1 { margin: 1rem 0 0; font-size: 2rem; font-weight: 600; letter-spacing: -0.02em; }
.btx-404 p { color: var(--muted); }
.btx-404 .btx-search { margin: 1.5rem auto 0; }

/* ---------- Motion ---------- */
@media (prefers-reduced-motion: reduce) { * { transition: none !important; scroll-behavior: auto !important; } }
