/*
Theme Name: WithStack
Theme URI: https://withstack.dev
Author: WithStack
Author URI: https://withstack.dev
Description: Ship faster with the right AI stack. An ultra-minimal editorial theme for developer blogs covering AI tools and developer productivity. Inspired by Linear.app and Vercel.com.
Version: 1.0.0
Requires at least: 6.0
Tested up to: 6.5
Requires PHP: 7.4
License: GNU General Public License v2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
Text Domain: withstack
Tags: blog, minimal, editorial, dark-mode, two-columns, custom-colors, translation-ready
*/

/* ==========================================================================
   Custom properties / theming
   ========================================================================== */

:root {
  --bg: #ffffff;
  --text: #0a0a0a;
  --accent: #4f46e5;
  --muted: #6b7280;
  --hairline: #ededed;
  --code-bg: #0d1117;
  --code-text: #e6edf3;
  --affiliate-bg: #f5f5ff;
  --glow: rgba(79, 70, 229, 0.03);

  --maxw: 680px;
  --feed-maxw: 1080px;

  --font-body: "DM Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-mono: "DM Mono", "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
}

:root[data-theme="dark"] {
  --bg: #0a0a0a;
  --text: #f5f5f5;
  --accent: #4f46e5;
  --muted: #9ca3af;
  --hairline: #1f1f1f;
  --code-bg: #0d1117;
  --code-text: #e6edf3;
  --affiliate-bg: #14142b;
  --glow: rgba(79, 70, 229, 0.05);
}

/* Auto dark mode when no manual preference has been set */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0a0a0a;
    --text: #f5f5f5;
    --accent: #4f46e5;
    --muted: #9ca3af;
    --hairline: #1f1f1f;
    --code-bg: #0d1117;
    --code-text: #e6edf3;
    --affiliate-bg: #14142b;
    --glow: rgba(79, 70, 229, 0.05);
  }
}

/* ==========================================================================
   Reset / base
   ========================================================================== */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background-color: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 17px;
  line-height: 1.8;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  transition: background-color 0.3s ease, color 0.3s ease;
}

a {
  color: inherit;
  text-decoration: none;
}

a:hover {
  color: var(--accent);
}

img {
  max-width: 100%;
  height: auto;
}

h1,
h2,
h3,
h4 {
  font-family: var(--font-mono);
  font-weight: 500;
  line-height: 1.25;
  letter-spacing: -0.02em;
  color: var(--text);
}

::selection {
  background: var(--accent);
  color: #fff;
}

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--accent);
  color: #fff;
  padding: 8px 16px;
  z-index: 1000;
}

.skip-link:focus {
  left: 8px;
  top: 8px;
}

.container {
  width: 100%;
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 0 24px;
}

.container-wide {
  width: 100%;
  max-width: var(--feed-maxw);
  margin: 0 auto;
  padding: 0 24px;
}

/* ==========================================================================
   Header
   ========================================================================== */

.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: color-mix(in srgb, var(--bg) 80%, transparent);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  backdrop-filter: saturate(180%) blur(12px);
}

.site-header__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
}

.site-logo {
  font-family: var(--font-mono);
  font-weight: 500;
  font-size: 18px;
  letter-spacing: -0.03em;
  color: var(--text);
}

.site-logo:hover {
  color: var(--text);
  opacity: 0.7;
}

.site-nav {
  display: flex;
  align-items: center;
  gap: 28px;
}

.site-nav__menu {
  display: flex;
  align-items: center;
  gap: 24px;
  list-style: none;
  margin: 0;
  padding: 0;
}

.site-nav__menu a {
  font-size: 14px;
  color: var(--muted);
  transition: color 0.2s ease;
}

.site-nav__menu a:hover {
  color: var(--text);
}

/* Dark mode toggle */
.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: color 0.2s ease, background 0.2s ease;
}

.theme-toggle:hover {
  color: var(--text);
  background: var(--hairline);
}

.theme-toggle svg {
  width: 18px;
  height: 18px;
}

.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;
  }
}

/* ==========================================================================
   Hero
   ========================================================================== */

.hero {
  position: relative;
  padding: 96px 0 64px;
  text-align: center;
  overflow: hidden;
}

.hero::before {
  content: "";
  position: absolute;
  top: -20%;
  left: 50%;
  width: 800px;
  height: 600px;
  transform: translateX(-50%);
  background: radial-gradient(circle, var(--glow) 0%, transparent 70%);
  pointer-events: none;
  z-index: -1;
}

.hero__title {
  font-size: clamp(32px, 6vw, 52px);
  margin: 0 0 20px;
  letter-spacing: -0.04em;
}

.hero__subtitle {
  font-size: 18px;
  color: var(--muted);
  max-width: 520px;
  margin: 0 auto;
  line-height: 1.6;
}

/* ==========================================================================
   Article feed
   ========================================================================== */

.feed {
  padding: 32px 0 96px;
}

.feed__grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px 48px;
}

@media (max-width: 720px) {
  .feed__grid {
    grid-template-columns: 1fr;
  }
}

.post-card {
  display: block;
  padding: 28px 0;
  border-bottom: 1px solid var(--hairline);
}

.post-card__meta {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.post-card__tag {
  font-family: var(--font-mono);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--accent);
}

.post-card__title {
  font-size: 21px;
  margin: 0 0 10px;
  line-height: 1.3;
  transition: color 0.2s ease;
}

.post-card:hover .post-card__title {
  color: var(--accent);
}

.post-card__excerpt {
  color: var(--muted);
  font-size: 15px;
  line-height: 1.6;
  margin: 0 0 14px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.post-card__footer {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  color: var(--muted);
}

.post-card__footer .dot {
  opacity: 0.4;
}

/* Fade-in for infinite scroll appended items */
.post-card.fade-in {
  opacity: 0;
  transition: opacity 0.3s ease;
}

.post-card.fade-in.is-visible {
  opacity: 1;
}

.feed__sentinel {
  height: 1px;
  width: 100%;
}

.feed__loading {
  text-align: center;
  padding: 32px 0;
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--muted);
  display: none;
}

.feed__loading.is-active {
  display: block;
}

/* ==========================================================================
   Single article
   ========================================================================== */

.reading-progress {
  position: fixed;
  top: 0;
  left: 0;
  height: 2px;
  width: 0;
  background: var(--accent);
  z-index: 200;
  transition: width 0.1s linear;
}

.article {
  padding: 64px 0 96px;
}

.article__hero {
  margin-bottom: 48px;
}

.article__meta {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
  font-size: 13px;
  color: var(--muted);
}

.article__category {
  font-family: var(--font-mono);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--accent);
}

.article__title {
  font-size: clamp(28px, 5vw, 42px);
  margin: 0 0 8px;
  letter-spacing: -0.03em;
}

.article__body {
  font-size: 17px;
  line-height: 1.8;
}

.article__body > * {
  margin-top: 0;
  margin-bottom: 1.6em;
}

.article__body h2 {
  font-size: 26px;
  margin-top: 2em;
  margin-bottom: 0.6em;
}

.article__body h3 {
  font-size: 20px;
  margin-top: 1.6em;
  margin-bottom: 0.5em;
}

.article__body a {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-thickness: 1px;
}

.article__body ul,
.article__body ol {
  padding-left: 1.4em;
}

.article__body li {
  margin-bottom: 0.5em;
}

.article__body blockquote {
  margin: 1.6em 0;
  padding-left: 20px;
  border-left: 2px solid var(--accent);
  color: var(--muted);
  font-style: italic;
}

.article__body img {
  border-radius: 8px;
}

/* Inline code */
.article__body :not(pre) > code {
  font-family: var(--font-mono);
  font-size: 0.88em;
  background: var(--hairline);
  padding: 0.15em 0.4em;
  border-radius: 4px;
}

/* Code blocks */
.code-block {
  position: relative;
  margin: 1.6em 0;
}

.code-block pre,
.article__body pre {
  background: var(--code-bg);
  color: var(--code-text);
  font-family: "JetBrains Mono", var(--font-mono);
  font-size: 14px;
  line-height: 1.6;
  padding: 20px;
  border-radius: 10px;
  overflow-x: auto;
}

.article__body pre code {
  background: none;
  padding: 0;
  font-size: inherit;
}

.code-copy {
  position: absolute;
  top: 10px;
  right: 10px;
  padding: 5px 10px;
  border: none;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.08);
  color: #e6edf3;
  font-family: var(--font-mono);
  font-size: 11px;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.2s ease, background 0.2s ease;
}

.code-block:hover .code-copy {
  opacity: 1;
}

.code-copy:hover {
  background: rgba(255, 255, 255, 0.16);
}

.code-copy.copied {
  background: var(--accent);
  color: #fff;
}

/* Affiliate boxes */
.affiliate-box {
  position: relative;
  background: var(--affiliate-bg);
  border-radius: 10px;
  padding: 24px 24px 20px;
  margin: 2em 0;
}

.affiliate-box__label {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent);
  margin-bottom: 10px;
}

.affiliate-box p:last-child {
  margin-bottom: 0;
}

/* AdSense slots */
.adsense-slot {
  margin: 2.5em 0;
  min-height: 90px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--hairline);
  border-radius: 8px;
  font-family: var(--font-mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

/* Sticky share bar */
.share-bar {
  position: fixed;
  left: max(24px, calc((100vw - var(--maxw)) / 2 - 64px));
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 50;
}

@media (max-width: 1000px) {
  .share-bar {
    display: none;
  }
}

.share-bar a,
.share-bar button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  padding: 0;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: color 0.2s ease, background 0.2s ease;
}

.share-bar a:hover,
.share-bar button:hover {
  color: var(--accent);
  background: var(--hairline);
}

.share-bar svg {
  width: 18px;
  height: 18px;
}

/* Next article (auto-loaded) */
.next-article {
  border-top: 1px solid var(--hairline);
  margin-top: 64px;
}

.next-article__label {
  font-family: var(--font-mono);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  text-align: center;
  padding: 48px 0 0;
}

/* ==========================================================================
   Footer
   ========================================================================== */

.site-footer {
  border-top: 1px solid var(--hairline);
  padding: 40px 0;
}

.site-footer__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
  font-size: 13px;
  color: var(--muted);
}

.site-footer__links {
  display: flex;
  gap: 20px;
  list-style: none;
  margin: 0;
  padding: 0;
}

.site-footer__links a:hover {
  color: var(--text);
}

@media (max-width: 540px) {
  .site-footer__inner {
    flex-direction: column;
    align-items: flex-start;
  }
}

/* ==========================================================================
   Utilities
   ========================================================================== */

.screen-reader-text {
  position: absolute !important;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(1px, 1px, 1px, 1px);
  white-space: nowrap;
  border: 0;
  padding: 0;
  margin: -1px;
}
