/*
Theme Name: GLCS Blog
Theme URI: https://blog.glcs.io
Description: Classic theme for the GLCS Julia blog. Ports the pipeline preview design (Open Sans + Rubik, brand tokens, dark mode with localStorage persistence, Shiki dual-theme code, KaTeX math). Pairs with the glcs-publish plugin: displays glcs_total_views(), the glcs_series taxonomy, and the _glcs_author byline. Fonts + KaTeX are vendored locally under assets/.
Version: 1.0.0
Author: Great Lakes Consulting Services
Author URI: https://glcs.io
Requires at least: 6.3
Requires PHP: 8.0
Text Domain: glcs-theme
*/

/*
 * GLCS blog theme — typography and brand tokens.
 *
 * Aesthetic direction: refined editorial. Long-form technical reading with
 * math, code, and figures. The page is a quiet stage; brand color enters as
 * deliberate punctuation (heading rule, tag pills, accent links, hero stripe).
 * Dark mode is purpose-designed — not a token inversion. It uses a calmer,
 * cooler brand-blue (`#7da3ff`) for legibility against the deep slate ground.
 *
 * Brand colors extracted from glcs.io's Divi theme builder CSS:
 *   #325CE8  primary brand blue   (buttons, accents, links)
 *   #63CABA  secondary teal       (tags, secondary highlights)
 *   #8300E9  accent purple        (rare emphasis)
 *
 * Fonts: Open Sans (body) + Rubik (headings) — same as the Divi-Child theme,
 * vendored locally (assets/fonts/*.woff2) rather than loaded from a CDN.
 */

/* ----- Vendored fonts (latin woff2; weights used by the design) --------- */

@font-face {
  font-family: "Open Sans";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('assets/fonts/open-sans-400.woff2') format('woff2');
}
@font-face {
  font-family: "Open Sans";
  font-style: italic;
  font-weight: 400;
  font-display: swap;
  src: url('assets/fonts/open-sans-400-italic.woff2') format('woff2');
}
@font-face {
  font-family: "Open Sans";
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url('assets/fonts/open-sans-500.woff2') format('woff2');
}
@font-face {
  font-family: "Open Sans";
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url('assets/fonts/open-sans-600.woff2') format('woff2');
}
@font-face {
  font-family: "Open Sans";
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url('assets/fonts/open-sans-700.woff2') format('woff2');
}
@font-face {
  font-family: "Rubik";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('assets/fonts/rubik-400.woff2') format('woff2');
}
@font-face {
  font-family: "Rubik";
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url('assets/fonts/rubik-500.woff2') format('woff2');
}
@font-face {
  font-family: "Rubik";
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url('assets/fonts/rubik-600.woff2') format('woff2');
}
@font-face {
  font-family: "Rubik";
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url('assets/fonts/rubik-700.woff2') format('woff2');
}

:root {
  --font-body: "Open Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-heading: "Rubik", "Open Sans", -apple-system, sans-serif;
  --font-mono: ui-monospace, "JetBrains Mono", "Fira Code", Consolas, "Liberation Mono", monospace;

  /* Brand palette (from glcs.io Divi theme) */
  --color-brand-blue: #325CE8;
  --color-brand-blue-hover: #1f44c4;
  --color-brand-teal: #63CABA;
  --color-brand-purple: #8300E9;

  /* Neutrals tuned for long-form reading */
  --color-text: #2a2a2a;
  --color-text-strong: #111111;
  --color-text-muted: #5f6c7b;
  --color-bg: #ffffff;
  --color-bg-subtle: #f7f9fd;
  --color-border: #e1e5ea;
  --color-code-bg: #f6f8fa;
  --color-code-text: #24292e;
  --color-header-bg: rgba(255, 255, 255, 0.86);
  --color-header-border: rgba(20, 28, 48, 0.08);
  --color-footer-bg: #0c1018;
  --color-footer-text: #c8cdd6;
  --color-figure-shadow: 0 1px 2px rgba(20, 28, 48, 0.04), 0 8px 24px rgba(20, 28, 48, 0.06);
  --color-figcaption: var(--color-text-muted);

  /* Accent (link / heading rule). Tracks brand-blue in light, shifts cooler
   * in dark so it reads on slate. Single token keeps recolor surgical. */
  --color-link: var(--color-brand-blue);
  --color-link-hover: var(--color-brand-blue-hover);
  --color-accent: var(--color-brand-blue);
  --color-accent-soft: rgba(50, 92, 232, 0.12);

  --max-width: 760px;
  --body-size: 18px;
  --line-height: 1.7;

  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;

  color-scheme: light;
}

/* ----- Dark mode tokens -------------------------------------------------- *
 * Two activation paths share the same overrides:
 *   1) [data-theme="dark"] on <html>      — explicit user choice via toggle
 *   2) prefers-color-scheme: dark         — OS preference when no manual
 *                                            choice has been stored
 * The pre-paint bootstrap in header.php sets data-theme="light"|"dark"
 * only when the user has explicitly toggled, so the media query controls
 * the default look.
 * ------------------------------------------------------------------------ */

:root[data-theme="dark"] {
  --color-text: #d6dae0;
  --color-text-strong: #f1f3f6;
  --color-text-muted: #8a96a8;
  --color-bg: #0d1117;
  --color-bg-subtle: #161b22;
  --color-border: #232b36;
  --color-code-bg: #161b22;
  --color-code-text: #e6edf3;
  --color-header-bg: rgba(13, 17, 23, 0.86);
  --color-header-border: rgba(180, 200, 240, 0.08);
  --color-footer-bg: #06080b;
  --color-footer-text: #c8cdd6;
  --color-figure-shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 8px 24px rgba(0, 0, 0, 0.45);

  /* Brand-blue shifted cooler/brighter for dark-bg legibility. */
  --color-link: #7da3ff;
  --color-link-hover: #a8c0ff;
  --color-accent: #7da3ff;
  --color-accent-soft: rgba(125, 163, 255, 0.16);

  color-scheme: dark;
}

/* Shiki's dual-theme output exposes the dark color/bg via CSS vars on each
 * token. Activate them when the page is in dark mode. */
:root[data-theme="dark"] .shiki,
:root[data-theme="dark"] .shiki span {
  color: var(--shiki-dark) !important;
  background-color: var(--shiki-dark-bg) !important;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --color-text: #d6dae0;
    --color-text-strong: #f1f3f6;
    --color-text-muted: #8a96a8;
    --color-bg: #0d1117;
    --color-bg-subtle: #161b22;
    --color-border: #232b36;
    --color-code-bg: #161b22;
    --color-code-text: #e6edf3;
    --color-header-bg: rgba(13, 17, 23, 0.86);
    --color-header-border: rgba(180, 200, 240, 0.08);
    --color-footer-bg: #06080b;
    --color-footer-text: #c8cdd6;
    --color-figure-shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 8px 24px rgba(0, 0, 0, 0.45);
    --color-link: #7da3ff;
    --color-link-hover: #a8c0ff;
    --color-accent: #7da3ff;
    --color-accent-soft: rgba(125, 163, 255, 0.16);
    color-scheme: dark;
  }
  :root:not([data-theme="light"]) .shiki,
  :root:not([data-theme="light"]) .shiki span {
    color: var(--shiki-dark) !important;
    background-color: var(--shiki-dark-bg) !important;
  }
}

/* ----- Reset + base ----------------------------------------------------- */

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-body);
  font-size: var(--body-size);
  line-height: var(--line-height);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  transition: background-color 240ms ease, color 240ms ease;
}

::selection {
  background: var(--color-accent-soft);
  color: var(--color-text-strong);
}

/* ----- Site header ------------------------------------------------------ */

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 16px 32px;
  background: var(--color-header-bg);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--color-header-border);
  position: sticky;
  top: 0;
  z-index: 10;
}
.site-header__brand { display: inline-flex; align-items: center; }
.site-header__logo {
  display: block;
  height: 32px;
  width: auto;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .site-header__logo { filter: brightness(1.05); }
}
:root[data-theme="dark"] .site-header__logo { filter: brightness(1.05); }

.site-header__right { display: flex; align-items: center; gap: 20px; }
.site-header__nav { display: flex; gap: 22px; }
.site-header__nav a {
  font-family: var(--font-heading);
  font-weight: 600;
  font-size: 0.92rem;
  color: var(--color-text-strong);
  text-decoration: none;
  letter-spacing: 0.01em;
  transition: color 160ms ease;
}
.site-header__nav a:hover { color: var(--color-accent); }
.site-header__nav a[aria-current="page"] {
  color: var(--color-accent);
  border-bottom: 2px solid var(--color-accent);
  padding-bottom: 2px;
}

/* Theme toggle button. Refined, square, brand-aware. */
.theme-toggle {
  -webkit-appearance: none;
  appearance: none;
  background: transparent;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  width: 34px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--color-text-strong);
  cursor: pointer;
  padding: 0;
  transition: color 160ms ease, border-color 160ms ease, background-color 160ms ease, transform 160ms ease;
}
.theme-toggle:hover {
  color: var(--color-accent);
  border-color: var(--color-accent);
  background: var(--color-accent-soft);
}
.theme-toggle:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}
.theme-toggle:active { transform: scale(0.96); }
.theme-toggle svg { width: 18px; height: 18px; display: block; }

/* Icon visibility: show sun in dark mode (click to go light), moon in light. */
.theme-toggle .icon-sun  { display: none; }
.theme-toggle .icon-moon { display: block; }
:root[data-theme="dark"] .theme-toggle .icon-sun  { display: block; }
:root[data-theme="dark"] .theme-toggle .icon-moon { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle .icon-sun  { display: block; }
  :root:not([data-theme="light"]) .theme-toggle .icon-moon { display: none; }
}

/* ----- Brand hero stripe ----------------------------------------------- */

.site-hero-stripe {
  height: 5px;
  background: linear-gradient(
    90deg,
    var(--color-brand-blue)   0%,
    var(--color-brand-blue)   55%,
    var(--color-brand-teal)   55%,
    var(--color-brand-teal)   85%,
    var(--color-brand-purple) 85%
  );
}

/* ----- Footer ----------------------------------------------------------- */

.site-footer {
  background: var(--color-footer-bg);
  color: var(--color-footer-text);
  margin-top: 96px;
  font-size: 0.9rem;
  border-top: 1px solid var(--color-border);
}
.site-footer__inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 28px 32px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
}
.site-footer__links { display: flex; gap: 18px; }
.site-footer a {
  color: var(--color-brand-teal);
  text-decoration: none;
  font-weight: 600;
  transition: color 160ms ease;
}
.site-footer a:hover { color: #ffffff; }

/* ----- Article container ----------------------------------------------- */

.post {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 56px 24px 96px;
}

.post-cover {
  margin: 0 0 40px;
}
.post-cover img {
  width: 100%;
  height: auto;
  border-radius: var(--radius-lg);
  box-shadow: var(--color-figure-shadow);
  background: var(--color-bg-subtle);
}

.post-header {
  margin-bottom: 56px;
  padding-left: 20px;
  border-left: 3px solid var(--color-accent);
}

.post-title {
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: clamp(2rem, 4.4vw, 2.75rem);
  line-height: 1.12;
  letter-spacing: -0.015em;
  margin: 0 0 14px;
  color: var(--color-text-strong);
}

.post-subtitle {
  font-family: var(--font-heading);
  font-weight: 400;
  font-size: 1.15rem;
  line-height: 1.45;
  color: var(--color-text-muted);
  margin: 0 0 18px;
}

.post-byline {
  color: var(--color-text-muted);
  font-size: 0.92rem;
  margin: 0 0 10px;
  letter-spacing: 0.01em;
}
.post-byline a {
  color: var(--color-accent);
  text-decoration: none;
}
.post-byline a:hover { text-decoration: underline; }

/* View count sits in the byline; kept as its own hook for Round 6 styling. */
.post-views { color: var(--color-text-muted); }

.post-tags {
  margin: 10px 0 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.post-tags li {
  background: var(--color-brand-teal);
  color: #06302b;             /* deep teal-shadow ink */
  font-family: var(--font-heading);
  font-weight: 600;
  font-size: 0.74rem;
  padding: 3px 11px;
  border-radius: 999px;
  text-transform: lowercase;
  letter-spacing: 0.03em;
}
.post-tags li a { color: inherit; text-decoration: none; border: none; }
:root[data-theme="dark"] .post-tags li { color: #06302b; }

/* ----- Body typography -------------------------------------------------- */

.post-body { font-size: var(--body-size); }

.post-body h1,
.post-body h2,
.post-body h3,
.post-body h4 {
  font-family: var(--font-heading);
  font-weight: 700;
  color: var(--color-text-strong);
  line-height: 1.25;
  margin-top: 2.2em;
  margin-bottom: 0.55em;
  letter-spacing: -0.005em;
}

/* H1/H2 share the same visual treatment: rule underneath, not full-width. */
.post-body h1,
.post-body h2 {
  font-size: 1.7rem;
  position: relative;
  padding-bottom: 0.5em;
}
.post-body h1::after,
.post-body h2::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: 0;
  width: 64px;
  height: 3px;
  background: linear-gradient(90deg, var(--color-accent), var(--color-brand-teal));
  border-radius: 2px;
}

.post-body h3 {
  font-size: 1.3rem;
  color: var(--color-accent);
}
.post-body h4 {
  font-size: 1.08rem;
  color: var(--color-text-strong);
}

.post-body p { margin: 0 0 1.2em; }

.post-body a {
  color: var(--color-link);
  text-decoration: none;
  border-bottom: 1px solid currentColor;
  transition: color 160ms ease;
}
.post-body a:hover { color: var(--color-link-hover); }

.post-body strong { color: var(--color-text-strong); }

/* ----- Blockquote ------------------------------------------------------- */

.post-body blockquote {
  margin: 1.6em 0;
  padding: 0.85em 1.4em;
  border-left: 3px solid var(--color-accent);
  background: var(--color-accent-soft);
  color: var(--color-text);
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
}
.post-body blockquote p:last-child { margin-bottom: 0; }

/* ----- Lists ----------------------------------------------------------- */

.post-body ul, .post-body ol {
  padding-left: 1.5em;
  margin: 0 0 1.2em;
}
.post-body li { margin: 0.3em 0; }
.post-body li::marker { color: var(--color-accent); }

/* ----- Tables ---------------------------------------------------------- */

.post-body table {
  border-collapse: collapse;
  width: 100%;
  margin: 1.8em 0;
  font-size: 0.94rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  overflow: hidden;
}
.post-body th, .post-body td {
  padding: 10px 14px;
  text-align: left;
  border-bottom: 1px solid var(--color-border);
}
.post-body tr:last-child td { border-bottom: none; }
.post-body th {
  background: var(--color-bg-subtle);
  font-family: var(--font-heading);
  font-weight: 600;
  letter-spacing: 0.01em;
  color: var(--color-text-strong);
}

/* ----- Images & figures ------------------------------------------------ *
 * Standalone images get wrapped in <figure> by render.ts. Raw <img> stays
 * supported (legacy / inline). Both modes get a subtle border + lift so
 * screenshots on a near-white or near-black page don't bleed into the bg.
 * ----------------------------------------------------------------------- */

.post-body figure {
  margin: 2em 0;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.post-body figure img,
.post-body > p > img,
.post-body img {
  max-width: 100%;
  height: auto;
  display: block;
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border);
  background: var(--color-bg-subtle);
  box-shadow: var(--color-figure-shadow);
}
.post-body figcaption {
  margin-top: 0.75em;
  font-family: var(--font-heading);
  font-weight: 400;
  font-size: 0.88rem;
  line-height: 1.45;
  color: var(--color-figcaption);
  text-align: center;
  max-width: 90%;
  font-style: normal;
}

/* ----- Inline code ----------------------------------------------------- */

.post-body :not(pre) > code {
  font-family: var(--font-mono);
  font-size: 0.86em;
  background: var(--color-bg-subtle);
  padding: 1px 7px;
  border-radius: var(--radius-sm);
  color: var(--color-accent);
  border: 1px solid var(--color-border);
}

/* ----- Code blocks (shiki) -------------------------------------------- */

.post-body pre {
  margin: 1.6em 0;
  padding: 18px 22px;
  border-radius: var(--radius-md);
  overflow-x: auto;
  font-size: 0.9rem;
  line-height: 1.6;
  background: var(--color-code-bg);
  border: 1px solid var(--color-border);
  color: var(--color-code-text);
  position: relative;
}
.post-body pre code {
  font-family: var(--font-mono);
  background: transparent;
  padding: 0;
  color: inherit;
  border: none;
}
.post-body .shiki { background-color: var(--color-code-bg) !important; }

/* Custom thin scrollbar for code blocks */
.post-body pre::-webkit-scrollbar { height: 8px; }
.post-body pre::-webkit-scrollbar-thumb {
  background: var(--color-border);
  border-radius: 4px;
}
.post-body pre::-webkit-scrollbar-thumb:hover { background: var(--color-text-muted); }

/* ----- Math ------------------------------------------------------------ */

.math-display {
  margin: 1.8em 0;
  overflow-x: auto;
  padding: 0.5em 0;
}

/* KaTeX uses currentColor for math glyphs in most cases, but a few elements
 * (rule lines, brace ornaments) bake in the default text color. Force them
 * to the active body color so dark mode reads correctly. */
.katex { color: var(--color-text-strong); }
.katex .frac-line,
.katex .overline-line,
.katex .underline-line,
.katex .vlist-r .hline {
  border-color: var(--color-text-strong);
}

/* ----- Footnotes ------------------------------------------------------- */

.post-body .footnotes {
  margin-top: 3.5em;
  border-top: 1px solid var(--color-border);
  padding-top: 1.2em;
  font-size: 0.9rem;
  color: var(--color-text-muted);
}
.post-body .footnotes a { color: var(--color-link); }

/* ----- Post lists (index / archive / tag / series) --------------------- *
 * Plain chronological cards. The richer homepage (search, filtering,
 * generative covers) is Round 6 (front-page.php); this is the functional
 * baseline so navigation and the per-tag RSS feeds keep working.
 * ----------------------------------------------------------------------- */

.site-main {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 48px 24px 96px;
}

.archive-header {
  border-bottom: 1px solid var(--color-border);
  margin-bottom: 40px;
  padding-bottom: 24px;
}
.archive-header h1 {
  font-family: var(--font-heading);
  font-size: 1.7rem;
  font-weight: 700;
  margin: 0 0 6px;
  color: var(--color-text-strong);
}
.archive-header p { color: var(--color-text-muted); font-size: 0.94rem; margin: 0; }

.post-card { border-bottom: 1px solid var(--color-border); padding: 32px 0; }
.post-card:first-of-type { padding-top: 0; }
.post-card__title {
  font-family: var(--font-heading);
  font-size: 1.35rem;
  font-weight: 700;
  margin: 0 0 8px;
  line-height: 1.2;
  color: var(--color-text-strong);
}
.post-card__title a { color: inherit; text-decoration: none; border-bottom: none; }
.post-card__title a:hover { color: var(--color-accent); }
.post-card__meta { font-size: 0.88rem; color: var(--color-text-muted); margin: 0 0 10px; }
.post-card__excerpt { font-size: 0.96rem; color: var(--color-text); margin: 0; line-height: 1.6; }
.post-card__tags { margin-top: 12px; }

.pagination {
  margin-top: 48px;
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
  font-family: var(--font-heading);
}
.pagination a, .pagination span {
  padding: 8px 14px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  color: var(--color-text);
  text-decoration: none;
  font-size: 0.9rem;
}
.pagination a:hover { border-color: var(--color-accent); color: var(--color-accent); }
.pagination .current {
  background: var(--color-accent);
  color: #fff;
  border-color: var(--color-accent);
}

/* ----- Small screens --------------------------------------------------- */

@media (max-width: 640px) {
  .site-header { padding: 14px 18px; }
  .site-header__nav { gap: 14px; }
  .site-header__nav a { font-size: 0.86rem; }
  .post { padding: 36px 18px 72px; }
  .post-header { padding-left: 14px; margin-bottom: 40px; }
  .post-body pre { padding: 14px 16px; font-size: 0.84rem; }
  .site-main { padding: 32px 18px 72px; }
}
